Skip to content

Commit d229ec7

Browse files
committed
Fix links and code blocks
1 parent 1714032 commit d229ec7

File tree

1 file changed

+46
-30
lines changed

1 file changed

+46
-30
lines changed

README.rst

+46-30
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ small project in a domain your users are familiar with, JSDoc's alphabetical
1010
list of routines might suffice. But in a larger project, it is useful to
1111
intersperse prose with your API docs without having to copy and paste things.
1212

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/>`__
1414
documentation tool with JS projects. It provides a handful of directives,
1515
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
1717
JSDoc-formatted documentation into reStructuredText pages. And, because you can
1818
keep using JSDoc in your code, you remain compatible with the rest of your JS
1919
tooling, like Google's Closure Compiler.
@@ -68,27 +68,39 @@ Setup
6868
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language.
6969
> Project language [en]:
7070

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``::
7373

7474
extensions = ['sphinx_js']
7575

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+
8698
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``::
88100

89101
primary_domain = 'js'
90102

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
92104
all the "js:" prefixes in the directives below.
93105

94106
Use
@@ -98,7 +110,7 @@ In short, in a Sphinx project, use the following directives to pull in your
98110
JSDoc documentation, then tell Sphinx to render it all by running ``make html``
99111
in your docs directory. If you have never used Sphinx or written
100112
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>`__.
102114
For a quick start, just add things to index.rst until you prove things are
103115
working.
104116

@@ -137,7 +149,7 @@ optional parameters::
137149

138150
Parameter properties and destructuring parameters also work fine, using
139151
`standard JSDoc syntax
140-
<https://jsdoc.app/tags-param.html#parameters-with-properties>`_::
152+
<https://jsdoc.app/tags-param.html#parameters-with-properties>`__::
141153

142154
/**
143155
* 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```)::
208220
:short-name:
209221

210222
``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>`__.
212224

213225
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
215227
result will be styled as a function, and ``@property`` tags will fall
216228
misleadingly under an "Arguments" heading. Still, it's better than nothing
217229
until we can do it properly.
@@ -315,7 +327,7 @@ disambiguate them. Here's a particularly long example::
315327
.. js:autofunction:: ./some/dir/some/file.SomeClass#someInstanceMethod.staticMethod~innerMember
316328

317329
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.
319331

320332
For conciseness, you can use any unique suffix, as long as it consists of
321333
complete path segments. These would all be equivalent to the above, assuming
@@ -332,7 +344,7 @@ Things to note:
332344
``external:`` or ``module:`` ones.
333345
* We use simple backslash escaping exclusively rather than switching escaping
334346
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
336348
be escaped are ``#.~(/``, though you do not need to escape the dots in a
337349
leading ``./`` or ``../``. A really horrible path might be::
338350

@@ -351,8 +363,11 @@ Behind the scenes, sphinx-js will change all separators to dots so that:
351363
Saving Keystrokes By Setting The Primary Domain
352364
-----------------------------------------------
353365

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``.
356371

357372
TypeScript: Getting Superclass and Interface Links To Work
358373
----------------------------------------------------------
@@ -370,7 +385,8 @@ Configuration Reference
370385
-----------------------
371386

372387
``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'.
374390

375391
``js_source_path``
376392
A list of directories to scan (non-recursively) for JS or TS source files,
@@ -398,10 +414,10 @@ Example
398414

399415
A good example using most of sphinx-js's functionality is the Fathom
400416
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.
403419

404-
`ReadTheDocs <https://readthedocs.org/>`_ is the canonical hosting platform for
420+
`ReadTheDocs <https://readthedocs.org/>`__ is the canonical hosting platform for
405421
Sphinx docs and now supports sphinx-js as an opt-in beta. Put this in the
406422
``.readthedocs.yml`` file at the root of your repo::
407423

@@ -415,9 +431,9 @@ example::
415431
sphinx-js==3.1.2
416432

417433
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>`__
419435
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>`__
421437
for building docs with sphinx-js and publishing them to GitHub Pages. Feel free
422438
to borrow them.
423439

0 commit comments

Comments
 (0)