Skip to content

Commit

Permalink
fix: Sphinx generated incorrect type references for display
Browse files Browse the repository at this point in the history
When rendering a type reference link, the trailing backtick must be followed by
a non-word character; however the code generated array and union references that
followed this backtick directly with `[` or `)` respectively. This caused a lot
of warnings to be emitted by `sphinx-build`, and resulted in incorrect output.

This adds an escaped space (`\ `) after the backticks, which `sphinx-build`
correctly interprets as a non-word character, but results in no character being
emitted to the output - thus generating the desired output.
  • Loading branch information
RomainMuller committed Sep 17, 2018
1 parent 845cc48 commit 4bed159
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/jsii-pacmak/lib/targets/sphinx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ class SphinxDocsGenerator extends Generator {
switch (type.collection.kind) {
case spec.CollectionKind.Array:
result = {
ref: `${ref}[]`,
display: `${display}[]`
ref: `${ref}\\ []`,
display: `${display}\\ []`
};
break;
case spec.CollectionKind.Map:
Expand All @@ -551,7 +551,7 @@ class SphinxDocsGenerator extends Generator {
// Wrap a string between parenthesis if it contains " or "
function wrap(str: string): string {
if (str.indexOf(' or ') === -1) { return str; }
return `(${str})`;
return `(${str}\\ )`;
}
}

Expand Down

0 comments on commit 4bed159

Please sign in to comment.