Skip to content

Commit b664805

Browse files
authored
fix: Sphinx generated incorrect type references for display (#232)
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.
1 parent 405da9c commit b664805

File tree

4 files changed

+91
-91
lines changed

4 files changed

+91
-91
lines changed

packages/jsii-pacmak/lib/targets/sphinx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ class SphinxDocsGenerator extends Generator {
504504
if (spec.isNamedTypeReference(type)) {
505505
const fqn = this.toNativeFqn(type.fqn);
506506
result = {
507-
ref: `:py:class:\`${type.fqn.startsWith(`${this.assembly.name}.`) ? '~' : ''}${fqn}\``,
507+
ref: `:py:class:\`${type.fqn.startsWith(`${this.assembly.name}.`) ? '~' : ''}${fqn}\`\\ `,
508508
display: fqn
509509
};
510510
} else if (spec.isPrimitiveTypeReference(type)) {

packages/jsii-pacmak/test/expected.jsii-calc-base/sphinx/_scope_jsii-calc-base.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ BaseProps (interface)
188188

189189

190190

191-
:extends: :py:class:`@scope/jsii-calc-base-of-base.VeryBaseProps`
191+
:extends: :py:class:`@scope/jsii-calc-base-of-base.VeryBaseProps`\
192192

193193

194194
.. py:attribute:: bar

packages/jsii-pacmak/test/expected.jsii-calc-lib/sphinx/_scope_jsii-calc-lib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Number
282282
Represents a concrete number.
283283

284284

285-
:extends: :py:class:`~@scope/jsii-calc-lib.Value`
285+
:extends: :py:class:`~@scope/jsii-calc-lib.Value`\
286286
:param value: The number.
287287
:type value: number
288288

@@ -332,7 +332,7 @@ Operation
332332
Represents an operation on values.
333333

334334

335-
:extends: :py:class:`~@scope/jsii-calc-lib.Value`
335+
:extends: :py:class:`~@scope/jsii-calc-lib.Value`\
336336
:abstract: Yes
337337

338338
.. py:method:: toString() -> string
@@ -424,7 +424,7 @@ Value
424424
Abstract class which represents a numeric value.
425425

426426

427-
:extends: :py:class:`@scope/jsii-calc-base.Base`
427+
:extends: :py:class:`@scope/jsii-calc-base.Base`\
428428
:abstract: Yes
429429

430430
.. py:method:: toString() -> string

0 commit comments

Comments
 (0)