@@ -10,10 +10,10 @@ small project in a domain your users are familiar with, JSDoc's alphabetical
10
10
list of routines might suffice. But in a larger project, it is useful to
11
11
intersperse prose with your API docs without having to copy and paste things.
12
12
13
- sphinx-js lets you use the industry-leading `Sphinx <http ://sphinx-doc.org/ >`_
13
+ sphinx-js lets you use the industry-leading `Sphinx <https ://sphinx-doc.org/ >`__
14
14
documentation tool with JS projects. It provides a handful of directives,
15
15
patterned after the Python-centric `autodoc
16
- <www.sphinx-doc.org/en/latest/ext/autodoc.html> `_ ones, for pulling
16
+ <https:// www.sphinx-doc.org/en/latest/ext/autodoc.html> `__ ones, for pulling
17
17
JSDoc-formatted documentation into reStructuredText pages. And, because you can
18
18
keep using JSDoc in your code, you remain compatible with the rest of your JS
19
19
tooling, like Google's Closure Compiler.
@@ -68,27 +68,39 @@ Setup
68
68
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language.
69
69
> Project language [en]:
70
70
71
- 4. In the generated Sphinx conf.py file, turn on ``sphinx_js `` by adding it to
72
- ``extensions ``::
71
+ 4. In the generated Sphinx `` conf.py `` file, turn on ``sphinx_js `` by adding it
72
+ to ``extensions ``::
73
73
74
74
extensions = ['sphinx_js']
75
75
76
- 5. If you want to document TypeScript, add ``js_language = 'typescript' `` to
77
- conf.py as well.
78
- 6. If your JS source code is anywhere but at the root of your project, add
79
- ``js_source_path = '../somewhere/else' `` on a line by itself in conf.py. The
80
- root of your JS source tree should be where that setting points, relative to
81
- the conf.py file. (The default, ``../ ``, works well when there is a ``docs ``
82
- folder at the root of your project and your source code lives directly
83
- inside the root.)
84
- 7. If you have special JSDoc or TypeDoc configuration, add ``jsdoc_config_path
85
- = '../conf.json' `` (for example) to conf.py as well.
76
+ 5. If you want to document TypeScript, add::
77
+
78
+ js_language = 'typescript'
79
+
80
+ to ``conf.py`` as well.
81
+
82
+ 6. If your JS source code is anywhere but at the root of your project, add::
83
+
84
+ js_source_path = '../somewhere/else'
85
+
86
+ on a line by itself in ``conf.py``. The root of your JS source tree should be
87
+ where that setting points, relative to the ``conf.py`` file.
88
+
89
+ The default, ``../``, works well when there is a ``docs`` folder at the root
90
+ of your project and your source code lives directly inside the root.
91
+
92
+ 7. If you have special JSDoc or TypeDoc configuration, add::
93
+
94
+ jsdoc_config_path = '../conf.json'
95
+
96
+ to ``conf.py`` as well.
97
+
86
98
8. If you're documenting only JS or TS and no other languages (like C), you can
87
- set your "primary domain" to JS in conf.py::
99
+ set your "primary domain" to JS in `` conf.py `` ::
88
100
89
101
primary_domain = 'js'
90
102
91
- ( The domain is ``js `` even if you're writing TypeScript.) Then you can omit
103
+ The domain is ``js `` even if you're writing TypeScript. Then you can omit
92
104
all the "js:" prefixes in the directives below.
93
105
94
106
Use
@@ -98,7 +110,7 @@ In short, in a Sphinx project, use the following directives to pull in your
98
110
JSDoc documentation, then tell Sphinx to render it all by running ``make html ``
99
111
in your docs directory. If you have never used Sphinx or written
100
112
reStructuredText before, here is `where we left off in its tutorial
101
- <http ://www.sphinx-doc.org/en/stable/tutorial.html#defining-document-structure> `_ .
113
+ <https ://www.sphinx-doc.org/en/stable/tutorial.html#defining-document-structure> `__ .
102
114
For a quick start, just add things to index.rst until you prove things are
103
115
working.
104
116
@@ -137,7 +149,7 @@ optional parameters::
137
149
138
150
Parameter properties and destructuring parameters also work fine, using
139
151
`standard JSDoc syntax
140
- <https://jsdoc.app/tags-param.html#parameters-with-properties> `_ ::
152
+ <https://jsdoc.app/tags-param.html#parameters-with-properties> `__ ::
141
153
142
154
/**
143
155
* Export an image from the given canvas and save it to the disk.
@@ -208,10 +220,10 @@ references must use the short name as well (``:func:`someFunction```)::
208
220
:short-name:
209
221
210
222
``autofunction `` can also be used on callbacks defined with the `@callback tag
211
- <https://jsdoc.app/tags-callback.html> `_ .
223
+ <https://jsdoc.app/tags-callback.html> `__ .
212
224
213
225
There is experimental support for abusing ``autofunction `` to document
214
- `@typedef tags <https://jsdoc.app/tags-typedef.html >`_ as well, though the
226
+ `@typedef tags <https://jsdoc.app/tags-typedef.html >`__ as well, though the
215
227
result will be styled as a function, and ``@property `` tags will fall
216
228
misleadingly under an "Arguments" heading. Still, it's better than nothing
217
229
until we can do it properly.
@@ -315,7 +327,7 @@ disambiguate them. Here's a particularly long example::
315
327
.. js:autofunction:: ./some/dir/some/file.SomeClass#someInstanceMethod.staticMethod~innerMember
316
328
317
329
You may recognize the separators ``#.~ `` from `JSDoc namepaths
318
- <https://jsdoc.app/about-namepaths.html> `_ ; they work the same here.
330
+ <https://jsdoc.app/about-namepaths.html> `__ ; they work the same here.
319
331
320
332
For conciseness, you can use any unique suffix, as long as it consists of
321
333
complete path segments. These would all be equivalent to the above, assuming
@@ -332,7 +344,7 @@ Things to note:
332
344
``external: `` or ``module: `` ones.
333
345
* We use simple backslash escaping exclusively rather than switching escaping
334
346
schemes halfway through the path; JSDoc itself `is headed that way as well
335
- <https://github.com/jsdoc3/jsdoc/issues/876> `_ . The characters that need to
347
+ <https://github.com/jsdoc3/jsdoc/issues/876> `__ . The characters that need to
336
348
be escaped are ``#.~(/ ``, though you do not need to escape the dots in a
337
349
leading ``./ `` or ``../ ``. A really horrible path might be::
338
350
@@ -351,8 +363,11 @@ Behind the scenes, sphinx-js will change all separators to dots so that:
351
363
Saving Keystrokes By Setting The Primary Domain
352
364
-----------------------------------------------
353
365
354
- To save some keystrokes, you can set ``primary_domain = 'js' `` in conf.py and
355
- then say (for example) ``autofunction `` rather than ``js:autofunction ``.
366
+ To save some keystrokes, you can set::
367
+
368
+ primary_domain = 'js'
369
+
370
+ in ``conf.py `` and then use ``autofunction `` rather than ``js:autofunction ``.
356
371
357
372
TypeScript: Getting Superclass and Interface Links To Work
358
373
----------------------------------------------------------
@@ -370,7 +385,8 @@ Configuration Reference
370
385
-----------------------
371
386
372
387
``js_language ``
373
- Use 'javascript' or 'typescript' depending on the language you use. The default is 'javascript'.
388
+ Use 'javascript' or 'typescript' depending on the language you use. The
389
+ default is 'javascript'.
374
390
375
391
``js_source_path ``
376
392
A list of directories to scan (non-recursively) for JS or TS source files,
@@ -398,10 +414,10 @@ Example
398
414
399
415
A good example using most of sphinx-js's functionality is the Fathom
400
416
documentation. A particularly juicy page is
401
- https://mozilla.github.io/fathom/ruleset.html. Click the "View page source"
402
- link to see the raw directives.
417
+ `< https://mozilla.github.io/fathom/ruleset.html >`__ . Click the "View page
418
+ source" link to see the raw directives.
403
419
404
- `ReadTheDocs <https://readthedocs.org/ >`_ is the canonical hosting platform for
420
+ `ReadTheDocs <https://readthedocs.org/ >`__ is the canonical hosting platform for
405
421
Sphinx docs and now supports sphinx-js as an opt-in beta. Put this in the
406
422
``.readthedocs.yml `` file at the root of your repo::
407
423
@@ -415,9 +431,9 @@ example::
415
431
sphinx-js==3.1.2
416
432
417
433
Or, if you prefer, the Fathom repo carries a `Travis CI configuration
418
- <https://github.com/mozilla/fathom/blob/92304b8ad4768e90c167c3d93f9865771f5a6d80/.travis.yml#L41> `_
434
+ <https://github.com/mozilla/fathom/blob/92304b8ad4768e90c167c3d93f9865771f5a6d80/.travis.yml#L41> `__
419
435
and a `deployment script
420
- <https://github.com/mozilla/fathom/blob/92304b8ad4768e90c167c3d93f9865771f5a6d80/tooling/travis-deploy-docs> `_
436
+ <https://github.com/mozilla/fathom/blob/92304b8ad4768e90c167c3d93f9865771f5a6d80/tooling/travis-deploy-docs> `__
421
437
for building docs with sphinx-js and publishing them to GitHub Pages. Feel free
422
438
to borrow them.
423
439
0 commit comments