Docs: ensure all functions include method signature #3777

This commit is contained in:
Lovell Fuller 2023-08-29 11:16:18 +01:00
parent 9c7713ed54
commit 67e927bdb6
11 changed files with 140 additions and 2 deletions

View File

@ -1,4 +1,6 @@
## removeAlpha ## removeAlpha
> removeAlpha() ⇒ <code>Sharp</code>
Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel. Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.
See also [flatten](/api-operation#flatten). See also [flatten](/api-operation#flatten).
@ -15,6 +17,8 @@ sharp('rgba.png')
## ensureAlpha ## ensureAlpha
> ensureAlpha([alpha]) ⇒ <code>Sharp</code>
Ensure the output image has an alpha transparency channel. Ensure the output image has an alpha transparency channel.
If missing, the added alpha channel will have the specified If missing, the added alpha channel will have the specified
transparency level, defaulting to fully-opaque (1). transparency level, defaulting to fully-opaque (1).
@ -48,6 +52,8 @@ const rgba = await sharp(rgb)
## extractChannel ## extractChannel
> extractChannel(channel) ⇒ <code>Sharp</code>
Extract a single channel from a multi-channel image. Extract a single channel from a multi-channel image.
@ -78,6 +84,8 @@ const [red1, red2, ...] = await sharp(input)
## joinChannel ## joinChannel
> joinChannel(images, options) ⇒ <code>Sharp</code>
Join one or more channels to the image. Join one or more channels to the image.
The meaning of the added channels depends on the output colourspace, set with `toColourspace()`. The meaning of the added channels depends on the output colourspace, set with `toColourspace()`.
By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels. By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
@ -102,6 +110,8 @@ For raw pixel input, the `options` object should contain a `raw` attribute, whic
## bandbool ## bandbool
> bandbool(boolOp) ⇒ <code>Sharp</code>
Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image. Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.

View File

@ -1,4 +1,6 @@
## tint ## tint
> tint(rgb) ⇒ <code>Sharp</code>
Tint the image using the provided chroma while preserving the image luminance. Tint the image using the provided chroma while preserving the image luminance.
An alpha channel may be present and will be unchanged by the operation. An alpha channel may be present and will be unchanged by the operation.
@ -21,6 +23,8 @@ const output = await sharp(input)
## greyscale ## greyscale
> greyscale([greyscale]) ⇒ <code>Sharp</code>
Convert to 8-bit greyscale; 256 shades of grey. Convert to 8-bit greyscale; 256 shades of grey.
This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results. This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results.
By default the output image will be web-friendly sRGB and contain three (identical) color channels. By default the output image will be web-friendly sRGB and contain three (identical) color channels.
@ -41,6 +45,8 @@ const output = await sharp(input).greyscale().toBuffer();
## grayscale ## grayscale
> grayscale([grayscale]) ⇒ <code>Sharp</code>
Alternative spelling of `greyscale`. Alternative spelling of `greyscale`.
@ -52,6 +58,8 @@ Alternative spelling of `greyscale`.
## pipelineColourspace ## pipelineColourspace
> pipelineColourspace([colourspace]) ⇒ <code>Sharp</code>
Set the pipeline colourspace. Set the pipeline colourspace.
The input image will be converted to the provided colourspace at the start of the pipeline. The input image will be converted to the provided colourspace at the start of the pipeline.
@ -82,6 +90,8 @@ await sharp(input)
## pipelineColorspace ## pipelineColorspace
> pipelineColorspace([colorspace]) ⇒ <code>Sharp</code>
Alternative spelling of `pipelineColourspace`. Alternative spelling of `pipelineColourspace`.
@ -97,6 +107,8 @@ Alternative spelling of `pipelineColourspace`.
## toColourspace ## toColourspace
> toColourspace([colourspace]) ⇒ <code>Sharp</code>
Set the output colourspace. Set the output colourspace.
By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels. By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
@ -120,6 +132,8 @@ await sharp(input)
## toColorspace ## toColorspace
> toColorspace([colorspace]) ⇒ <code>Sharp</code>
Alternative spelling of `toColourspace`. Alternative spelling of `toColourspace`.

View File

@ -1,4 +1,6 @@
## composite ## composite
> composite(images) ⇒ <code>Sharp</code>
Composite image(s) over the processed (resized, extracted etc.) image. Composite image(s) over the processed (resized, extracted etc.) image.
The images to composite must be the same size or smaller than the processed image. The images to composite must be the same size or smaller than the processed image.

View File

@ -1,9 +1,13 @@
## Sharp ## Sharp
> Sharp
**Emits**: <code>Sharp#event:info</code>, <code>Sharp#event:warning</code> **Emits**: <code>Sharp#event:info</code>, <code>Sharp#event:warning</code>
<a name="new_Sharp_new"></a> <a name="new_Sharp_new"></a>
### new ### new
> new Sharp([input], [options])
Constructor factory to create an instance of `sharp`, to which further methods are chained. Constructor factory to create an instance of `sharp`, to which further methods are chained.
JPEG, PNG, WebP, GIF, AVIF or TIFF format image data can be streamed out from this object. JPEG, PNG, WebP, GIF, AVIF or TIFF format image data can be streamed out from this object.
@ -159,6 +163,8 @@ await sharp({
## clone ## clone
> clone() ⇒ [<code>Sharp</code>](#Sharp)
Take a "snapshot" of the Sharp instance, returning a new instance. Take a "snapshot" of the Sharp instance, returning a new instance.
Cloned instances inherit the input of their parent instance. Cloned instances inherit the input of their parent instance.
This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream. This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.

View File

@ -1,4 +1,6 @@
## metadata ## metadata
> metadata([callback]) ⇒ <code>Promise.&lt;Object&gt;</code> \| <code>Sharp</code>
Fast access to (uncached) image metadata without decoding any compressed pixel data. Fast access to (uncached) image metadata without decoding any compressed pixel data.
This is read from the header of the input image. This is read from the header of the input image.
@ -81,6 +83,8 @@ function getNormalSize({ width, height, orientation }) {
## stats ## stats
> stats([callback]) ⇒ <code>Promise.&lt;Object&gt;</code>
Access to pixel-derived image statistics for every channel in the image. Access to pixel-derived image statistics for every channel in the image.
A `Promise` is returned when `callback` is not provided. A `Promise` is returned when `callback` is not provided.

View File

@ -1,4 +1,6 @@
## rotate ## rotate
> rotate([angle], [options]) ⇒ <code>Sharp</code>
Rotate the output image by either an explicit angle Rotate the output image by either an explicit angle
or auto-orient based on the EXIF `Orientation` tag. or auto-orient based on the EXIF `Orientation` tag.
@ -57,6 +59,8 @@ const resizeThenRotate = await sharp(input)
## flip ## flip
> flip([flip]) ⇒ <code>Sharp</code>
Mirror the image vertically (up-down) about the x-axis. Mirror the image vertically (up-down) about the x-axis.
This always occurs before rotation, if any. This always occurs before rotation, if any.
@ -75,6 +79,8 @@ const output = await sharp(input).flip().toBuffer();
## flop ## flop
> flop([flop]) ⇒ <code>Sharp</code>
Mirror the image horizontally (left-right) about the y-axis. Mirror the image horizontally (left-right) about the y-axis.
This always occurs before rotation, if any. This always occurs before rotation, if any.
@ -91,6 +97,8 @@ const output = await sharp(input).flop().toBuffer();
## affine ## affine
> affine(matrix, [options]) ⇒ <code>Sharp</code>
Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any. Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.
You must provide an array of length 4 or a 2x2 affine transformation matrix. You must provide an array of length 4 or a 2x2 affine transformation matrix.
@ -142,6 +150,8 @@ inputStream
## sharpen ## sharpen
> sharpen([options], [flat], [jagged]) ⇒ <code>Sharp</code>
Sharpen the image. Sharpen the image.
When used without parameters, performs a fast, mild sharpen of the output image. When used without parameters, performs a fast, mild sharpen of the output image.
@ -193,6 +203,8 @@ const data = await sharp(input)
## median ## median
> median([size]) ⇒ <code>Sharp</code>
Apply median filter. Apply median filter.
When used without parameters the default window is 3x3. When used without parameters the default window is 3x3.
@ -217,6 +229,8 @@ const output = await sharp(input).median(5).toBuffer();
## blur ## blur
> blur([sigma]) ⇒ <code>Sharp</code>
Blur the image. Blur the image.
When used without parameters, performs a fast 3x3 box blur (equivalent to a box linear filter). When used without parameters, performs a fast 3x3 box blur (equivalent to a box linear filter).
@ -248,6 +262,8 @@ const gaussianBlurred = await sharp(input)
## flatten ## flatten
> flatten([options]) ⇒ <code>Sharp</code>
Merge alpha transparency channel, if any, with a background, then remove the alpha channel. Merge alpha transparency channel, if any, with a background, then remove the alpha channel.
See also [removeAlpha](/api-channel#removealpha). See also [removeAlpha](/api-channel#removealpha).
@ -268,6 +284,8 @@ await sharp(rgbaInput)
## unflatten ## unflatten
> unflatten()
Ensure the image has an alpha channel Ensure the image has an alpha channel
with all white pixel values made fully transparent. with all white pixel values made fully transparent.
@ -293,6 +311,8 @@ await sharp(rgbInput)
## gamma ## gamma
> gamma([gamma], [gammaOut]) ⇒ <code>Sharp</code>
Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of `1/gamma` Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of `1/gamma`
then increasing the encoding (brighten) post-resize at a factor of `gamma`. then increasing the encoding (brighten) post-resize at a factor of `gamma`.
This can improve the perceived brightness of a resized image in non-linear colour spaces. This can improve the perceived brightness of a resized image in non-linear colour spaces.
@ -315,6 +335,8 @@ Supply a second argument to use a different output gamma value, otherwise the fi
## negate ## negate
> negate([options]) ⇒ <code>Sharp</code>
Produce the "negative" of the image. Produce the "negative" of the image.
@ -339,6 +361,8 @@ const output = await sharp(input)
## normalise ## normalise
> normalise([options]) ⇒ <code>Sharp</code>
Enhance output image contrast by stretching its luminance to cover a full dynamic range. Enhance output image contrast by stretching its luminance to cover a full dynamic range.
Uses a histogram-based approach, taking a default range of 1% to 99% to reduce sensitivity to noise at the extremes. Uses a histogram-based approach, taking a default range of 1% to 99% to reduce sensitivity to noise at the extremes.
@ -369,6 +393,8 @@ const output = await sharp(input)
## normalize ## normalize
> normalize([options]) ⇒ <code>Sharp</code>
Alternative spelling of normalise. Alternative spelling of normalise.
@ -388,6 +414,8 @@ const output = await sharp(input)
## clahe ## clahe
> clahe(options) ⇒ <code>Sharp</code>
Perform contrast limiting adaptive histogram equalization Perform contrast limiting adaptive histogram equalization
[CLAHE](https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE). [CLAHE](https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE).
@ -419,6 +447,8 @@ const output = await sharp(input)
## convolve ## convolve
> convolve(kernel) ⇒ <code>Sharp</code>
Convolve the image with the specified kernel. Convolve the image with the specified kernel.
@ -453,6 +483,8 @@ sharp(input)
## threshold ## threshold
> threshold([threshold], [options]) ⇒ <code>Sharp</code>
Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0. Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
@ -471,6 +503,8 @@ Any pixel value greater than or equal to the threshold value will be set to 255,
## boolean ## boolean
> boolean(operand, operator, [options]) ⇒ <code>Sharp</code>
Perform a bitwise boolean operation with operand image. Perform a bitwise boolean operation with operand image.
This operation creates an output image where each pixel is the result of This operation creates an output image where each pixel is the result of
@ -495,6 +529,8 @@ the selected bitwise boolean `operation` between the corresponding pixels of the
## linear ## linear
> linear([a], [b]) ⇒ <code>Sharp</code>
Apply the linear formula `a` * input + `b` to the image to adjust image levels. Apply the linear formula `a` * input + `b` to the image to adjust image levels.
When a single number is provided, it will be used for all image channels. When a single number is provided, it will be used for all image channels.
@ -529,6 +565,8 @@ await sharp(rgbInput)
## recomb ## recomb
> recomb(inputMatrix) ⇒ <code>Sharp</code>
Recombine the image with the specified matrix. Recombine the image with the specified matrix.
@ -559,6 +597,8 @@ sharp(input)
## modulate ## modulate
> modulate([options]) ⇒ <code>Sharp</code>
Transforms the image using brightness, saturation, hue rotation, and lightness. Transforms the image using brightness, saturation, hue rotation, and lightness.
Brightness and lightness both operate on luminance, with the difference being that Brightness and lightness both operate on luminance, with the difference being that
brightness is multiplicative whereas lightness is additive. brightness is multiplicative whereas lightness is additive.

View File

@ -1,4 +1,6 @@
## toFile ## toFile
> toFile(fileOut, [callback]) ⇒ <code>Promise.&lt;Object&gt;</code>
Write output image data to a file. Write output image data to a file.
If an explicit output format is not selected, it will be inferred from the extension, If an explicit output format is not selected, it will be inferred from the extension,
@ -39,6 +41,8 @@ sharp(input)
## toBuffer ## toBuffer
> toBuffer([options], [callback]) ⇒ <code>Promise.&lt;Buffer&gt;</code>
Write output to a Buffer. Write output to a Buffer.
JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported. JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.
@ -108,6 +112,8 @@ await sharp(pixelArray, { raw: { width, height, channels } })
## withMetadata ## withMetadata
> withMetadata([options]) ⇒ <code>Sharp</code>
Include all metadata (EXIF, XMP, IPTC) from the input image in the output image. Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
This will also convert to and add a web-friendly sRGB ICC profile if appropriate, This will also convert to and add a web-friendly sRGB ICC profile if appropriate,
unless a custom output profile is provided. unless a custom output profile is provided.
@ -167,6 +173,8 @@ const data = await sharp(input)
## toFormat ## toFormat
> toFormat(format, options) ⇒ <code>Sharp</code>
Force output to a given format. Force output to a given format.
@ -190,6 +198,8 @@ const data = await sharp(input)
## jpeg ## jpeg
> jpeg([options]) ⇒ <code>Sharp</code>
Use these JPEG options for output image. Use these JPEG options for output image.
@ -235,6 +245,8 @@ const data = await sharp(input)
## png ## png
> png([options]) ⇒ <code>Sharp</code>
Use these PNG options for output image. Use these PNG options for output image.
By default, PNG output is full colour at 8 or 16 bits per pixel. By default, PNG output is full colour at 8 or 16 bits per pixel.
@ -278,6 +290,8 @@ const data = await sharp(input)
## webp ## webp
> webp([options]) ⇒ <code>Sharp</code>
Use these WebP options for output image. Use these WebP options for output image.
@ -319,6 +333,8 @@ const outputWebp = await sharp(inputWebp, { animated: true })
## gif ## gif
> gif([options]) ⇒ <code>Sharp</code>
Use these GIF options for the output image. Use these GIF options for the output image.
The first entry in the palette is reserved for transparency. The first entry in the palette is reserved for transparency.
@ -378,6 +394,8 @@ await sharp('in.gif', { animated: true })
## jp2 ## jp2
> jp2([options]) ⇒ <code>Sharp</code>
Use these JP2 options for output image. Use these JP2 options for output image.
Requires libvips compiled with support for OpenJPEG. Requires libvips compiled with support for OpenJPEG.
@ -420,6 +438,8 @@ const data = await sharp(input)
## tiff ## tiff
> tiff([options]) ⇒ <code>Sharp</code>
Use these TIFF options for output image. Use these TIFF options for output image.
The `density` can be set in pixels/inch via [withMetadata](#withmetadata) The `density` can be set in pixels/inch via [withMetadata](#withmetadata)
@ -461,6 +481,8 @@ sharp('input.svg')
## avif ## avif
> avif([options]) ⇒ <code>Sharp</code>
Use these AVIF options for output image. Use these AVIF options for output image.
Whilst it is possible to create AVIF images smaller than 16x16 pixels, Whilst it is possible to create AVIF images smaller than 16x16 pixels,
@ -498,6 +520,8 @@ const data = await sharp(input)
## heif ## heif
> heif([options]) ⇒ <code>Sharp</code>
Use these HEIF options for output image. Use these HEIF options for output image.
Support for patent-encumbered HEIC images using `hevc` compression requires the use of a Support for patent-encumbered HEIC images using `hevc` compression requires the use of a
@ -528,6 +552,8 @@ const data = await sharp(input)
## jxl ## jxl
> jxl([options]) ⇒ <code>Sharp</code>
Use these JPEG-XL (JXL) options for output image. Use these JPEG-XL (JXL) options for output image.
This feature is experimental, please do not use in production systems. This feature is experimental, please do not use in production systems.
@ -557,6 +583,8 @@ Image metadata (EXIF, XMP) is unsupported.
## raw ## raw
> raw([options])
Force output to be raw, uncompressed pixel data. Force output to be raw, uncompressed pixel data.
Pixel ordering is left-to-right, top-to-bottom, without padding. Pixel ordering is left-to-right, top-to-bottom, without padding.
Channel ordering will be RGB or RGBA for non-greyscale colourspaces. Channel ordering will be RGB or RGBA for non-greyscale colourspaces.
@ -592,6 +620,8 @@ const data = await sharp('input.png')
## tile ## tile
> tile([options]) ⇒ <code>Sharp</code>
Use tile-based deep zoom (image pyramid) output. Use tile-based deep zoom (image pyramid) output.
Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions. Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.
@ -653,6 +683,8 @@ readableStream
## timeout ## timeout
> timeout(options) ⇒ <code>Sharp</code>
Set a timeout for processing, in seconds. Set a timeout for processing, in seconds.
Use a value of zero to continue processing indefinitely, the default behaviour. Use a value of zero to continue processing indefinitely, the default behaviour.

View File

@ -1,4 +1,6 @@
## resize ## resize
> resize([width], [height], [options]) ⇒ <code>Sharp</code>
Resize image to `width`, `height` or `width x height`. Resize image to `width`, `height` or `width x height`.
When both a `width` and `height` are provided, the possible methods by which the image should **fit** these are: When both a `width` and `height` are provided, the possible methods by which the image should **fit** these are:
@ -146,6 +148,8 @@ const scaleByHalf = await sharp(input)
## extend ## extend
> extend(extend) ⇒ <code>Sharp</code>
Extend / pad / extrude one or more edges of the image with either Extend / pad / extrude one or more edges of the image with either
the provided background colour or pixels derived from the image. the provided background colour or pixels derived from the image.
This operation will always occur after resizing and extraction, if any. This operation will always occur after resizing and extraction, if any.
@ -204,6 +208,8 @@ sharp(input)
## extract ## extract
> extract(options) ⇒ <code>Sharp</code>
Extract/crop a region of the image. Extract/crop a region of the image.
- Use `extract` before `resize` for pre-resize extraction. - Use `extract` before `resize` for pre-resize extraction.
@ -245,6 +251,8 @@ sharp(input)
## trim ## trim
> trim(trim) ⇒ <code>Sharp</code>
Trim pixels from all edges that contain values similar to the given background colour, which defaults to that of the top-left pixel. Trim pixels from all edges that contain values similar to the given background colour, which defaults to that of the top-left pixel.
Images with an alpha channel will use the combined bounding box of alpha and non-alpha channels. Images with an alpha channel will use the combined bounding box of alpha and non-alpha channels.

View File

@ -1,4 +1,6 @@
## versions ## versions
> versions
An Object containing the version numbers of sharp, libvips and its dependencies. An Object containing the version numbers of sharp, libvips and its dependencies.
@ -9,6 +11,8 @@ console.log(sharp.versions);
## interpolators ## interpolators
> interpolators : <code>enum</code>
An Object containing the available interpolators and their proper values An Object containing the available interpolators and their proper values
@ -27,6 +31,8 @@ An Object containing the available interpolators and their proper values
## format ## format
> format ⇒ <code>Object</code>
An Object containing nested boolean values representing the available input and output formats/methods. An Object containing nested boolean values representing the available input and output formats/methods.
@ -37,6 +43,8 @@ console.log(sharp.format);
## vendor ## vendor
> vendor
An Object containing the platform and architecture An Object containing the platform and architecture
of the current and installed vendored binaries. of the current and installed vendored binaries.
@ -48,6 +56,8 @@ console.log(sharp.vendor);
## queue ## queue
> queue
An EventEmitter that emits a `change` event when a task is either: An EventEmitter that emits a `change` event when a task is either:
- queued, waiting for _libuv_ to provide a worker thread - queued, waiting for _libuv_ to provide a worker thread
- complete - complete
@ -62,6 +72,8 @@ sharp.queue.on('change', function(queueLength) {
## cache ## cache
> cache([options]) ⇒ <code>Object</code>
Gets or, when options are provided, sets the limits of _libvips'_ operation cache. Gets or, when options are provided, sets the limits of _libvips'_ operation cache.
Existing entries in the cache will be trimmed after any change in limits. Existing entries in the cache will be trimmed after any change in limits.
This method always returns cache statistics, This method always returns cache statistics,
@ -89,6 +101,8 @@ sharp.cache(false);
## concurrency ## concurrency
> concurrency([concurrency]) ⇒ <code>number</code>
Gets or, when a concurrency is provided, sets Gets or, when a concurrency is provided, sets
the maximum number of threads _libvips_ should use to process _each image_. the maximum number of threads _libvips_ should use to process _each image_.
These are from a thread pool managed by glib, These are from a thread pool managed by glib,
@ -132,6 +146,8 @@ sharp.concurrency(0); // 4
## counters ## counters
> counters() ⇒ <code>Object</code>
Provides access to internal task counters. Provides access to internal task counters.
- queue is the number of tasks this module has queued waiting for _libuv_ to provide a worker thread from its pool. - queue is the number of tasks this module has queued waiting for _libuv_ to provide a worker thread from its pool.
- process is the number of resize tasks currently being processed. - process is the number of resize tasks currently being processed.
@ -144,6 +160,8 @@ const counters = sharp.counters(); // { queue: 2, process: 4 }
## simd ## simd
> simd([simd]) ⇒ <code>boolean</code>
Get and set use of SIMD vector unit instructions. Get and set use of SIMD vector unit instructions.
Requires libvips to have been compiled with liborc support. Requires libvips to have been compiled with liborc support.
@ -169,6 +187,8 @@ const simd = sharp.simd(false);
## block ## block
> block(options)
Block libvips operations at runtime. Block libvips operations at runtime.
This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable, This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,
@ -191,6 +211,8 @@ sharp.block({
## unblock ## unblock
> unblock(options)
Unblock libvips operations at runtime. Unblock libvips operations at runtime.
This is useful for defining a list of allowed operations. This is useful for defining a list of allowed operations.

View File

@ -29,7 +29,7 @@ const jsdoc2md = require('jsdoc-to-markdown');
}); });
const cleanMarkdown = markdown const cleanMarkdown = markdown
.replace(/(## [A-Za-z0-9]+)[^\n]*/g, '$1') // simplify headings to match those of documentationjs, ensures existing URLs work .replace(/(## )([A-Za-z0-9]+)([^\n]*)/g, '$1$2\n> $2$3\n') // simplify headings to match those of documentationjs, ensures existing URLs work
.replace(/<a name="[A-Za-z0-9+]+"><\/a>/g, '') // remove anchors, let docute add these (at markdown to HTML render time) .replace(/<a name="[A-Za-z0-9+]+"><\/a>/g, '') // remove anchors, let docute add these (at markdown to HTML render time)
.replace(/\*\*Kind\*\*: global[^\n]+/g, '') // remove all "global" Kind labels (requires JSDoc refactoring) .replace(/\*\*Kind\*\*: global[^\n]+/g, '') // remove all "global" Kind labels (requires JSDoc refactoring)
.trim(); .trim();

View File

@ -40,7 +40,7 @@ for (const match of matches) {
].forEach((section) => { ].forEach((section) => {
const contents = fs.readFileSync(path.join(__dirname, '..', `api-${section}.md`), 'utf8'); const contents = fs.readFileSync(path.join(__dirname, '..', `api-${section}.md`), 'utf8');
const matches = contents.matchAll( const matches = contents.matchAll(
/## (?<title>[A-Za-z]+)\n(?<firstparagraph>.+?)\n\n.+?(?<parameters>\| Param .+?\n\n)?\*\*Example/gs /## (?<title>[A-Za-z]+)\n[^\n]+\n(?<firstparagraph>.+?)\n\n.+?(?<parameters>\| Param .+?\n\n)?\*\*Example/gs
); );
for (const match of matches) { for (const match of matches) {
const { title, firstparagraph, parameters } = match.groups; const { title, firstparagraph, parameters } = match.groups;