mdextract(src, options)
Extracts source documents.
var mdextract = require('mdextract');
var doc = mdextract(source);
console.log(doc.toMarkdown());
Returns a Document instance.
new Document(options)
A document represents a bunch of source code. A mdextract call will return a Document instance.
var mdextract = require('mdextract');
var doc = mdextract(source);
Options available:
forceHeadings
(boolean) — If true, sections without headings will be ignored.lang
(string) — Language to be used. Defaults to"js"
.
When invoking mdextract from the command line with a --json
option, the
result is a JSONified Document instance.
The available options as received through the Document constructor. Example:
doc = mdextract(source);
doc.options
=> { lang: "js" }
The list of section blocks as parsed away from the source. This is an array of Block instances.
doc = mdextract(source);
doc.blocks
=> [
{ internal: false,
docline: 55,
codeline: 66,
level: 3,
heading: "A heading",
body: "This is the body in *markdown* format." },
{ ... },
...
]
.toMarkdown(options)
Converts the document to markdown. Returns the Markdown string.
doc = mdextract(source);
console.log(doc.toMarkdown());
=> "## heading\nthis is stuff extracted from your source.\n..."
Available options are:
showInternal
(boolean) — renders internal/private API if true.
A section block. Options:
docline
(number) — line number where the documentation startscodeline
(number) — line number where code startslevel
(number) — heading levelheading
(string) — heading textsubheading
(string, optional) — optional subheading textbody
(string) — body text