antsibull-docs
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,32 +5,48 @@ # antsibull\-docs \-\- TypeScript library for processing Ansible documentation markup Release Notes | ||
- <a href="#v1-0-1">v1\.0\.1</a> | ||
- <a href="#v1-0-2">v1\.0\.2</a> | ||
- <a href="#release-summary">Release Summary</a> | ||
- <a href="#bugfixes">Bugfixes</a> | ||
- <a href="#v1-0-1">v1\.0\.1</a> | ||
- <a href="#release-summary-1">Release Summary</a> | ||
- <a href="#bugfixes-1">Bugfixes</a> | ||
- <a href="#v1-0-0">v1\.0\.0</a> | ||
- <a href="#release-summary-1">Release Summary</a> | ||
- <a href="#release-summary-2">Release Summary</a> | ||
- <a href="#v0-4-0">v0\.4\.0</a> | ||
- <a href="#release-summary-2">Release Summary</a> | ||
- <a href="#release-summary-3">Release Summary</a> | ||
- <a href="#minor-changes">Minor Changes</a> | ||
- <a href="#breaking-changes--porting-guide">Breaking Changes / Porting Guide</a> | ||
- <a href="#bugfixes-1">Bugfixes</a> | ||
- <a href="#bugfixes-2">Bugfixes</a> | ||
- <a href="#v0-3-0">v0\.3\.0</a> | ||
- <a href="#release-summary-3">Release Summary</a> | ||
- <a href="#release-summary-4">Release Summary</a> | ||
- <a href="#minor-changes-1">Minor Changes</a> | ||
- <a href="#v0-2-0">v0\.2\.0</a> | ||
- <a href="#release-summary-4">Release Summary</a> | ||
- <a href="#release-summary-5">Release Summary</a> | ||
- <a href="#minor-changes-2">Minor Changes</a> | ||
- <a href="#breaking-changes--porting-guide-1">Breaking Changes / Porting Guide</a> | ||
- <a href="#bugfixes-2">Bugfixes</a> | ||
- <a href="#bugfixes-3">Bugfixes</a> | ||
- <a href="#v0-1-0">v0\.1\.0</a> | ||
- <a href="#release-summary-5">Release Summary</a> | ||
- <a href="#release-summary-6">Release Summary</a> | ||
- <a href="#minor-changes-3">Minor Changes</a> | ||
- <a href="#breaking-changes--porting-guide-2">Breaking Changes / Porting Guide</a> | ||
- <a href="#bugfixes-3">Bugfixes</a> | ||
- <a href="#bugfixes-4">Bugfixes</a> | ||
- <a href="#v0-0-1">v0\.0\.1</a> | ||
- <a href="#release-summary-6">Release Summary</a> | ||
- <a href="#release-summary-7">Release Summary</a> | ||
<a id="v1-0-2"></a> | ||
## v1\.0\.2 | ||
<a id="release-summary"></a> | ||
### Release Summary | ||
Bugfix release\. | ||
<a id="bugfixes"></a> | ||
### Bugfixes | ||
* Fix handling of empty markup parameters for RST \([https\://github\.com/ansible\-community/antsibull\-docs\-ts/pull/262](https\://github\.com/ansible\-community/antsibull\-docs\-ts/pull/262)\)\. | ||
<a id="v1-0-1"></a> | ||
## v1\.0\.1 | ||
<a id="release-summary"></a> | ||
<a id="release-summary-1"></a> | ||
### Release Summary | ||
@@ -40,3 +56,3 @@ | ||
<a id="bugfixes"></a> | ||
<a id="bugfixes-1"></a> | ||
### Bugfixes | ||
@@ -49,3 +65,3 @@ | ||
<a id="release-summary-1"></a> | ||
<a id="release-summary-2"></a> | ||
### Release Summary | ||
@@ -58,3 +74,3 @@ | ||
<a id="release-summary-2"></a> | ||
<a id="release-summary-3"></a> | ||
### Release Summary | ||
@@ -74,3 +90,3 @@ | ||
<a id="bugfixes-1"></a> | ||
<a id="bugfixes-2"></a> | ||
### Bugfixes | ||
@@ -83,3 +99,3 @@ | ||
<a id="release-summary-3"></a> | ||
<a id="release-summary-4"></a> | ||
### Release Summary | ||
@@ -97,3 +113,3 @@ | ||
<a id="release-summary-4"></a> | ||
<a id="release-summary-5"></a> | ||
### Release Summary | ||
@@ -122,3 +138,3 @@ | ||
<a id="bugfixes-2"></a> | ||
<a id="bugfixes-3"></a> | ||
### Bugfixes | ||
@@ -131,3 +147,3 @@ | ||
<a id="release-summary-5"></a> | ||
<a id="release-summary-6"></a> | ||
### Release Summary | ||
@@ -152,3 +168,3 @@ | ||
<a id="bugfixes-3"></a> | ||
<a id="bugfixes-4"></a> | ||
### Bugfixes | ||
@@ -162,5 +178,5 @@ | ||
<a id="release-summary-6"></a> | ||
<a id="release-summary-7"></a> | ||
### Release Summary | ||
Initial release\. |
@@ -8,3 +8,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toAnsibleDocText = void 0; | ||
exports.toAnsibleDocText = toAnsibleDocText; | ||
const opts_1 = require("./opts"); | ||
@@ -51,3 +51,2 @@ const format_1 = require("./format"); | ||
} | ||
exports.toAnsibleDocText = toAnsibleDocText; | ||
//# sourceMappingURL=ansible-doc-text.js.map |
@@ -8,7 +8,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isPluginType = exports.isFQCN = void 0; | ||
exports.isFQCN = isFQCN; | ||
exports.isPluginType = isPluginType; | ||
function isFQCN(input) { | ||
return input.match(/^[a-z0-9_]+\.[a-z0-9_]+(?:\.[a-z0-9_]+)+$/) !== null; | ||
} | ||
exports.isFQCN = isFQCN; | ||
function isPluginType(input) { | ||
@@ -18,3 +18,2 @@ /* We do not want to hard-code a list of valid plugin types that might be inaccurate, so we simply check whether this is a valid kind of Python identifier usually used for plugin types. If ansible-core ever adds one with digits, we'll have to update this. */ | ||
} | ||
exports.isPluginType = isPluginType; | ||
//# sourceMappingURL=ansible.js.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addToDestination = void 0; | ||
exports.addToDestination = addToDestination; | ||
const dom_1 = require("./dom"); | ||
@@ -82,3 +82,2 @@ function addToDestination(destination, paragraph, opts) { | ||
} | ||
exports.addToDestination = addToDestination; | ||
//# sourceMappingURL=format.js.map |
@@ -8,3 +8,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toHTML = exports.quoteHTMLArg = exports.quoteHTML = void 0; | ||
exports.quoteHTML = quoteHTML; | ||
exports.quoteHTMLArg = quoteHTMLArg; | ||
exports.toHTML = toHTML; | ||
const opts_1 = require("./opts"); | ||
@@ -15,7 +17,5 @@ const format_1 = require("./format"); | ||
} | ||
exports.quoteHTML = quoteHTML; | ||
function quoteHTMLArg(text) { | ||
return quoteHTML(text).replace(/"/g, '"'); | ||
} | ||
exports.quoteHTMLArg = quoteHTMLArg; | ||
function formatOptionLikePlain(part, url, what) { | ||
@@ -126,3 +126,2 @@ let link_start = ''; | ||
} | ||
exports.toHTML = toHTML; | ||
//# sourceMappingURL=html.js.map |
@@ -8,3 +8,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toMD = exports.quoteMD = void 0; | ||
exports.quoteMD = quoteMD; | ||
exports.toMD = toMD; | ||
// CommonMark spec: https://spec.commonmark.org/current/ | ||
@@ -17,3 +18,2 @@ const opts_1 = require("./opts"); | ||
} | ||
exports.quoteMD = quoteMD; | ||
function formatOptionLike(part, url, what) { | ||
@@ -73,3 +73,2 @@ let link_start = ''; | ||
} | ||
exports.toMD = toMD; | ||
//# sourceMappingURL=md.js.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mergeOpts = void 0; | ||
exports.mergeOpts = mergeOpts; | ||
function mergeOpts(options, fallback) { | ||
@@ -22,3 +22,2 @@ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ | ||
} | ||
exports.mergeOpts = mergeOpts; | ||
//# sourceMappingURL=opts.js.map |
@@ -8,3 +8,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseUnescapedArgs = exports.parseEscapedArgs = void 0; | ||
exports.parseEscapedArgs = parseEscapedArgs; | ||
exports.parseUnescapedArgs = parseUnescapedArgs; | ||
function lstripSpace(input) { | ||
@@ -78,3 +79,2 @@ let index = 0; | ||
} | ||
exports.parseEscapedArgs = parseEscapedArgs; | ||
function parseUnescapedArgs(input, index, count) { | ||
@@ -112,3 +112,2 @@ const result = []; | ||
} | ||
exports.parseUnescapedArgs = parseUnescapedArgs; | ||
//# sourceMappingURL=parser-impl.js.map |
@@ -8,3 +8,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parse = exports.parseString = exports.composeCommandRE = exports.composeCommandMap = void 0; | ||
exports.composeCommandMap = composeCommandMap; | ||
exports.composeCommandRE = composeCommandRE; | ||
exports.parseString = parseString; | ||
exports.parse = parse; | ||
const ansible_1 = require("./ansible"); | ||
@@ -208,3 +211,2 @@ const parser_impl_1 = require("./parser-impl"); | ||
} | ||
exports.composeCommandMap = composeCommandMap; | ||
function commandRE(command) { | ||
@@ -216,3 +218,2 @@ return '\\b' + command.command + (command.parameters === 0 ? '\\b' : '\\('); | ||
} | ||
exports.composeCommandRE = composeCommandRE; | ||
const PARSER_COMMANDS = composeCommandMap(PARSER); | ||
@@ -305,3 +306,2 @@ const COMMAND_RE = composeCommandRE(PARSER); | ||
} | ||
exports.parseString = parseString; | ||
/** | ||
@@ -320,3 +320,2 @@ Parses a string or a list of strings to a list of paragraphs. | ||
} | ||
exports.parse = parse; | ||
//# sourceMappingURL=parser.js.map |
@@ -8,6 +8,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toRST = exports.quoteRST = void 0; | ||
exports.quoteRST = quoteRST; | ||
exports.toRST = toRST; | ||
const opts_1 = require("./opts"); | ||
const format_1 = require("./format"); | ||
function quoteRST(text, escape_starting_whitespace = false, escape_ending_whitespace = false) { | ||
function quoteRST(text, escape_starting_whitespace = false, escape_ending_whitespace = false, must_not_be_empty = false) { | ||
text = text.replace(/([\\<>_*`])/g, '\\$1'); | ||
@@ -20,5 +21,7 @@ if (escape_ending_whitespace && text.endsWith(' ')) { | ||
} | ||
if (must_not_be_empty && text === '') { | ||
text = '\\ '; | ||
} | ||
return text; | ||
} | ||
exports.quoteRST = quoteRST; | ||
function formatAntsibullOptionLike(part, role) { | ||
@@ -41,3 +44,3 @@ const result = []; | ||
} | ||
return `\\ :${role}:\`${quoteRST(result.join(''), true, true)}\`\\ `; | ||
return `\\ :${role}:\`${quoteRST(result.join(''), true, true, true)}\`\\ `; | ||
} | ||
@@ -65,19 +68,19 @@ function formatPlainOptionLike(part) { | ||
const pluginText = plugin.length ? ` (of ${plugin.join('')})` : ''; | ||
const mainText = `:literal:\`${quoteRST(value, true, true)}\``; | ||
const mainText = `:literal:\`${quoteRST(value, true, true, true)}\``; | ||
return `\\ ${mainText}${pluginText}\\ `; | ||
} | ||
const DEFAULT_FORMATTER = { | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatHorizontalLine: () => '\n\n.. raw:: html\n\n <hr>\n\n', | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatLink: (part) => `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `, | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text)} <${part.ref}>\`\\ `, | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatLink: (part) => (part.text === '' ? '' : `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `), | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn, true, true, true)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text, true, true, true)} <${part.ref}>\`\\ `, | ||
formatURL: (part) => `\\ ${encodeURI(part.url)}\\ `, | ||
formatText: (part) => quoteRST(part.text), | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true)}\`\\ `, | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true, true)}\`\\ `, | ||
formatOptionName: (part) => formatAntsibullOptionLike(part, 'ansopt'), | ||
formatOptionValue: (part) => `\\ :ansval:\`${quoteRST(part.value, true, true)}\`\\ `, | ||
formatOptionValue: (part) => `\\ :ansval:\`${quoteRST(part.value, true, true, true)}\`\\ `, | ||
formatPlugin: (part) => `\\ :ref:\`${quoteRST(part.plugin.fqcn)} <ansible_collections.${part.plugin.fqcn}_${part.plugin.type}>\`\\ `, | ||
@@ -87,15 +90,15 @@ formatReturnValue: (part) => formatAntsibullOptionLike(part, 'ansretval'), | ||
const PLAIN_FORMATTER = { | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatHorizontalLine: () => '\n\n------------\n\n', | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatLink: (part) => `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `, | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text)} <${part.ref}>\`\\ `, | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatLink: (part) => (part.text === '' ? '' : `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `), | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn, true, true, true)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text, true, true, true)} <${part.ref}>\`\\ `, | ||
formatURL: (part) => `\\ ${encodeURI(part.url)}\\ `, | ||
formatText: (part) => quoteRST(part.text), | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true)}\`\\ `, | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true, true)}\`\\ `, | ||
formatOptionName: (part) => formatPlainOptionLike(part), | ||
formatOptionValue: (part) => `\\ :literal:\`${quoteRST(part.value, true, true)}\`\\ `, | ||
formatOptionValue: (part) => `\\ :literal:\`${quoteRST(part.value, true, true, true)}\`\\ `, | ||
formatPlugin: (part) => `\\ :ref:\`${quoteRST(part.plugin.fqcn)} <ansible_collections.${part.plugin.fqcn}_${part.plugin.type}>\`\\ `, | ||
@@ -119,3 +122,2 @@ formatReturnValue: (part) => formatPlainOptionLike(part), | ||
} | ||
exports.toRST = toRST; | ||
//# sourceMappingURL=rst.js.map |
import { RSTOptions } from './opts'; | ||
import { Paragraph } from './dom'; | ||
export declare function quoteRST(text: string, escape_starting_whitespace?: boolean, escape_ending_whitespace?: boolean): string; | ||
export declare function quoteRST(text: string, escape_starting_whitespace?: boolean, escape_ending_whitespace?: boolean, must_not_be_empty?: boolean): string; | ||
export declare function toRST(paragraphs: Paragraph[], opts?: RSTOptions): string; | ||
//# sourceMappingURL=rst.d.ts.map |
@@ -8,3 +8,3 @@ /* | ||
import { addToDestination } from './format'; | ||
export function quoteRST(text, escape_starting_whitespace = false, escape_ending_whitespace = false) { | ||
export function quoteRST(text, escape_starting_whitespace = false, escape_ending_whitespace = false, must_not_be_empty = false) { | ||
text = text.replace(/([\\<>_*`])/g, '\\$1'); | ||
@@ -17,2 +17,5 @@ if (escape_ending_whitespace && text.endsWith(' ')) { | ||
} | ||
if (must_not_be_empty && text === '') { | ||
text = '\\ '; | ||
} | ||
return text; | ||
@@ -37,3 +40,3 @@ } | ||
} | ||
return `\\ :${role}:\`${quoteRST(result.join(''), true, true)}\`\\ `; | ||
return `\\ :${role}:\`${quoteRST(result.join(''), true, true, true)}\`\\ `; | ||
} | ||
@@ -61,19 +64,19 @@ function formatPlainOptionLike(part) { | ||
const pluginText = plugin.length ? ` (of ${plugin.join('')})` : ''; | ||
const mainText = `:literal:\`${quoteRST(value, true, true)}\``; | ||
const mainText = `:literal:\`${quoteRST(value, true, true, true)}\``; | ||
return `\\ ${mainText}${pluginText}\\ `; | ||
} | ||
const DEFAULT_FORMATTER = { | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatHorizontalLine: () => '\n\n.. raw:: html\n\n <hr>\n\n', | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatLink: (part) => `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `, | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text)} <${part.ref}>\`\\ `, | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatLink: (part) => (part.text === '' ? '' : `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `), | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn, true, true, true)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text, true, true, true)} <${part.ref}>\`\\ `, | ||
formatURL: (part) => `\\ ${encodeURI(part.url)}\\ `, | ||
formatText: (part) => quoteRST(part.text), | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true)}\`\\ `, | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true, true)}\`\\ `, | ||
formatOptionName: (part) => formatAntsibullOptionLike(part, 'ansopt'), | ||
formatOptionValue: (part) => `\\ :ansval:\`${quoteRST(part.value, true, true)}\`\\ `, | ||
formatOptionValue: (part) => `\\ :ansval:\`${quoteRST(part.value, true, true, true)}\`\\ `, | ||
formatPlugin: (part) => `\\ :ref:\`${quoteRST(part.plugin.fqcn)} <ansible_collections.${part.plugin.fqcn}_${part.plugin.type}>\`\\ `, | ||
@@ -83,15 +86,15 @@ formatReturnValue: (part) => formatAntsibullOptionLike(part, 'ansretval'), | ||
const PLAIN_FORMATTER = { | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatHorizontalLine: () => '\n\n------------\n\n', | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatLink: (part) => `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `, | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text)} <${part.ref}>\`\\ `, | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatLink: (part) => (part.text === '' ? '' : `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `), | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn, true, true, true)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text, true, true, true)} <${part.ref}>\`\\ `, | ||
formatURL: (part) => `\\ ${encodeURI(part.url)}\\ `, | ||
formatText: (part) => quoteRST(part.text), | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true)}\`\\ `, | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true, true)}\`\\ `, | ||
formatOptionName: (part) => formatPlainOptionLike(part), | ||
formatOptionValue: (part) => `\\ :literal:\`${quoteRST(part.value, true, true)}\`\\ `, | ||
formatOptionValue: (part) => `\\ :literal:\`${quoteRST(part.value, true, true, true)}\`\\ `, | ||
formatPlugin: (part) => `\\ :ref:\`${quoteRST(part.plugin.fqcn)} <ansible_collections.${part.plugin.fqcn}_${part.plugin.type}>\`\\ `, | ||
@@ -98,0 +101,0 @@ formatReturnValue: (part) => formatPlainOptionLike(part), |
{ | ||
"name": "antsibull-docs", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "TypeScript library for processing Ansible documentation markup", | ||
@@ -55,4 +55,4 @@ "main": "dist/cjs/index.js", | ||
"@types/jest": "^29.5.12", | ||
"@typescript-eslint/eslint-plugin": "^7.0.1", | ||
"@typescript-eslint/parser": "^7.0.1", | ||
"@typescript-eslint/eslint-plugin": "^7.6.0", | ||
"@typescript-eslint/parser": "^7.6.0", | ||
"eslint": "^8.56.0", | ||
@@ -63,5 +63,5 @@ "jest": "^29.7.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3", | ||
"yaml": "^2.3.4" | ||
"typescript": "^5.4.5", | ||
"yaml": "^2.4.1" | ||
} | ||
} |
@@ -13,2 +13,3 @@ <!-- | ||
[![Codecov badge](https://img.shields.io/codecov/c/github/ansible-community/antsibull-docs-ts)](https://codecov.io/gh/ansible-community/antsibull-docs-ts) | ||
[![REUSE status](https://api.reuse.software/badge/github.com/ansible-community/antsibull-docs-ts)](https://api.reuse.software/info/github.com/ansible-community/antsibull-docs-ts) | ||
@@ -15,0 +16,0 @@ This is a TypeScript library for processing Ansible documentation markup. It is named after [the Python package of the same name](https://github.com/ansible-community/antsibull-docs/). It is the TypeScript/JavaScript version of the Python [antsibull-docs-parser](https://github.com/ansible-community/antsibull-docs-parser/) package, which is used by antsibull-docs. |
@@ -24,4 +24,7 @@ /* | ||
it('simple string, escape spacing', (): void => { | ||
expect(quoteRST(' foo ', true, true)).toBe('\\ foo \\ '); | ||
expect(quoteRST(' foo ', true, true, true)).toBe('\\ foo \\ '); | ||
}); | ||
it('simple string, escape empty', (): void => { | ||
expect(quoteRST('', true, true, true)).toBe('\\ '); | ||
}); | ||
it('more complex', (): void => { | ||
@@ -28,0 +31,0 @@ expect(quoteRST('\\<_>`*<_>*`\\')).toBe('\\\\\\<\\_\\>\\`\\*\\<\\_\\>\\*\\`\\\\'); |
@@ -11,3 +11,8 @@ /* | ||
export function quoteRST(text: string, escape_starting_whitespace = false, escape_ending_whitespace = false): string { | ||
export function quoteRST( | ||
text: string, | ||
escape_starting_whitespace = false, | ||
escape_ending_whitespace = false, | ||
must_not_be_empty = false, | ||
): string { | ||
text = text.replace(/([\\<>_*`])/g, '\\$1'); | ||
@@ -21,2 +26,5 @@ | ||
} | ||
if (must_not_be_empty && text === '') { | ||
text = '\\ '; | ||
} | ||
return text; | ||
@@ -42,3 +50,3 @@ } | ||
} | ||
return `\\ :${role}:\`${quoteRST(result.join(''), true, true)}\`\\ `; | ||
return `\\ :${role}:\`${quoteRST(result.join(''), true, true, true)}\`\\ `; | ||
} | ||
@@ -69,3 +77,3 @@ | ||
const pluginText = plugin.length ? ` (of ${plugin.join('')})` : ''; | ||
const mainText = `:literal:\`${quoteRST(value, true, true)}\``; | ||
const mainText = `:literal:\`${quoteRST(value, true, true, true)}\``; | ||
return `\\ ${mainText}${pluginText}\\ `; | ||
@@ -75,15 +83,16 @@ } | ||
const DEFAULT_FORMATTER: AllFormatOptions = { | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatHorizontalLine: () => '\n\n.. raw:: html\n\n <hr>\n\n', | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatLink: (part) => `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `, | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text)} <${part.ref}>\`\\ `, | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatLink: (part) => (part.text === '' ? '' : `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `), | ||
formatModule: (part) => | ||
`\\ :ref:\`${quoteRST(part.fqcn, true, true, true)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text, true, true, true)} <${part.ref}>\`\\ `, | ||
formatURL: (part) => `\\ ${encodeURI(part.url)}\\ `, | ||
formatText: (part) => quoteRST(part.text), | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true)}\`\\ `, | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true, true)}\`\\ `, | ||
formatOptionName: (part) => formatAntsibullOptionLike(part, 'ansopt'), | ||
formatOptionValue: (part) => `\\ :ansval:\`${quoteRST(part.value, true, true)}\`\\ `, | ||
formatOptionValue: (part) => `\\ :ansval:\`${quoteRST(part.value, true, true, true)}\`\\ `, | ||
formatPlugin: (part) => | ||
@@ -95,15 +104,16 @@ `\\ :ref:\`${quoteRST(part.plugin.fqcn)} <ansible_collections.${part.plugin.fqcn}_${part.plugin.type}>\`\\ `, | ||
const PLAIN_FORMATTER: AllFormatOptions = { | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatError: (part) => `\\ :strong:\`ERROR while parsing\`\\ : ${quoteRST(part.message, true, true, true)}\\ `, | ||
formatBold: (part) => `\\ :strong:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatCode: (part) => `\\ :literal:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatHorizontalLine: () => '\n\n------------\n\n', | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true)}\`\\ `, | ||
formatLink: (part) => `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `, | ||
formatModule: (part) => `\\ :ref:\`${quoteRST(part.fqcn)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text)} <${part.ref}>\`\\ `, | ||
formatItalic: (part) => `\\ :emphasis:\`${quoteRST(part.text, true, true, true)}\`\\ `, | ||
formatLink: (part) => (part.text === '' ? '' : `\\ \`${quoteRST(part.text)} <${encodeURI(part.url)}>\`__\\ `), | ||
formatModule: (part) => | ||
`\\ :ref:\`${quoteRST(part.fqcn, true, true, true)} <ansible_collections.${part.fqcn}_module>\`\\ `, | ||
formatRSTRef: (part) => `\\ :ref:\`${quoteRST(part.text, true, true, true)} <${part.ref}>\`\\ `, | ||
formatURL: (part) => `\\ ${encodeURI(part.url)}\\ `, | ||
formatText: (part) => quoteRST(part.text), | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true)}\`\\ `, | ||
formatEnvVariable: (part) => `\\ :envvar:\`${quoteRST(part.name, true, true, true)}\`\\ `, | ||
formatOptionName: (part) => formatPlainOptionLike(part), | ||
formatOptionValue: (part) => `\\ :literal:\`${quoteRST(part.value, true, true)}\`\\ `, | ||
formatOptionValue: (part) => `\\ :literal:\`${quoteRST(part.value, true, true, true)}\`\\ `, | ||
formatPlugin: (part) => | ||
@@ -110,0 +120,0 @@ `\\ :ref:\`${quoteRST(part.plugin.fqcn)} <ansible_collections.${part.plugin.fqcn}_${part.plugin.type}>\`\\ `, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
415347
4301
120