@@ -67,6 +67,8 @@ with relevant tags. These are used to compile indices and generate cross-links b
6767commands, both in the HTML documents and in-game. See the list of available `tag-list ` and
6868think about which categories your new tool belongs in.
6969
70+ .. _docs-links :
71+
7072Links
7173-----
7274
@@ -418,6 +420,8 @@ Once you have pip available, you can install Sphinx with the following command::
418420Note that this may require opening a new (admin) command prompt if you just
419421installed pip from the same command prompt.
420422
423+ .. _docs-build :
424+
421425Building the documentation
422426==========================
423427
@@ -427,16 +431,18 @@ Sphinx to build the docs:
427431Using CMake
428432-----------
429433
430- See our page on `build options <building-documentation> `
434+ See our page on `build options <building-documentation> `.
431435
432- Running Sphinx manually
433- -----------------------
436+ Using the documentation build script
437+ ------------------------------------
434438
435439You can also build the documentation without running CMake - this is faster if
436- you only want to rebuild the documentation regardless of any code changes. The
437- ``docs/build.py `` script will build the documentation in any specified formats
438- (HTML only by default) using the same command that CMake runs when building the
439- docs. Run the script with ``--help `` to see additional options.
440+ you only want to rebuild the documentation regardless of any code changes.
441+
442+ The recommended approach is the ``docs/build.py `` script. This is the same
443+ script that CMake uses internally, which wraps Sphinx with a few additional
444+ options to handle common cases and can build multiple documentation formats with
445+ a single invocation.
440446
441447Examples:
442448
@@ -449,15 +455,43 @@ Examples:
449455* ``docs/build.py --clean ``
450456 Build HTML and force a clean build (all source files are re-read)
451457
452- The resulting documentation will be stored in ``docs/html `` and/or ``docs/text ``.
458+ * ``docs/build.py --help ``
459+ Display a full list of available options
460+
461+ The resulting documentation will be stored in ``docs/html `` and/or ``docs/text ``
462+ (or generally, a subfolder of ``docs/ `` named after the requested output format(s)).
463+
464+ Building a PDF version
465+ ----------------------
466+
467+ ReadTheDocs automatically builds a PDF version of the documentation (available
468+ under the "Downloads" section when clicking on the release selector). If you
469+ want to build a PDF version locally, you will need the ``pdflatex `` command, which is part
470+ of a TeX distribution. The following command will then build a PDF, located in
471+ ``docs/pdf/latex/DFHack.pdf ``, with default options::
472+
473+ docs/build.py pdf
474+
475+ Running Sphinx manually
476+ -----------------------
477+
478+ If ``docs/build.py `` does not support what you need, you can also run Sphinx
479+ manually. This is primarily useful for low-level debugging.
453480
454- Alternatively, you can run Sphinx manually with::
481+ For a good starting point, add the ``--debug `` argument to your call to
482+ ``docs/build.py ``. This will cause the script to print out the Sphinx command(s)
483+ that it is running.
455484
456- sphinx-build . docs/html
485+ Some examples:
457486
458- or, to build plain-text output::
487+ * ``sphinx-build . docs/html ``
488+ Build the HTML docs (equivalent to ``docs/build.py ``)
459489
460- sphinx-build -b text . docs/text
490+ * ``sphinx-build -b text . docs/text ``
491+ Build the plain text docs (equivalent to ``docs/build.py text ``)
492+
493+ * ``sphinx-build -M latexpdf . docs/pdf ``
494+ Build the PDF docs
461495
462496Sphinx has many options to enable clean builds, parallel builds, logging, and
463497more - run ``sphinx-build --help `` for details. If you specify a different
@@ -466,20 +500,47 @@ folder. Also be aware that when running ``sphinx-build`` directly, the
466500``docs/html `` folder may be polluted with intermediate build files that normally
467501get written in the cmake ``build `` directory.
468502
469- Building a PDF version
470- ----------------------
503+ Troubleshooting
504+ ===============
471505
472- ReadTheDocs automatically builds a PDF version of the documentation (available
473- under the "Downloads" section when clicking on the release selector). If you
474- want to build a PDF version locally, you will need ``pdflatex ``, which is part
475- of a TeX distribution. The following command will then build a PDF, located in
476- ``docs/pdf/latex/DFHack.pdf ``, with default options::
506+ Sphinx errors are typically printed by Sphinx, so ensure that you are not silencing Sphinx output.
477507
478- docs/build.py pdf
508+ When built with ``docs/build.py `` or CMake, errors are also logged to
509+ ``build/docs/<format>/sphinx-warnings.txt `` (for instance, if you are building
510+ the HTML docs, ``build/docs/html/sphinx-warnings.txt ``).
511+
512+
513+ "undefined label"
514+ -----------------
515+
516+ Typical causes:
517+
518+ * You have used single backticks for an inline code snippet, where double backticks should be used instead (see `docs-links `)::
519+
520+ `this is an invalid inline code snippet (actually a link)`
521+ ``this is a valid inline code snippet``
522+
523+ * You are attempting to link to a section/label, but either it does not have a label defined or you have spelled it incorrectly::
524+
525+ .. my-label:
526+
527+ This is where the link should go to.
528+
529+ ...
530+
531+ This is `a valid link to the earlier label <my-label>`. So is `my-label`.
532+
533+ "toctree contains reference to document that doesn't have a title"
534+ ------------------------------------------------------------------
535+
536+ Due to the nature of our autogenerated documentation, this can sometimes occur
537+ when switching between branches that have different autogenerated files, and can
538+ result in autogenerated documentation (e.g. for individual tools) being missing
539+ from the table of contents, or links failing to generate.
479540
480- Alternatively, you can run Sphinx manually with ::
541+ The quickest resolution is a clean docs build ::
481542
482- sphinx-build -M latexpdf . docs/pdf
543+ docs/build.py --clean
483544
484545.. _build-changelog :
485546
@@ -515,8 +576,8 @@ Changelog syntax
515576----------------
516577
517578.. include :: /docs/changelog.txt
518- :start-after: ===help
519- :end-before: ===end
579+ :start-after: ===syntax-reference-start
580+ :end-before: ===syntax-reference- end
520581
521582.. _docs-ci :
522583
0 commit comments