Skip to content

Commit

Permalink
DOC: separate source file for references
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Feb 25, 2023
1 parent 78088ab commit 4df8cb3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
20 changes: 1 addition & 19 deletions doc/a-normal-rst-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,7 @@ You can create a list of references in any reStructuredText file
.. bibliography::
Have a look at the documentation for all the available options.

The list of references may look something like this (in HTML output):

.. bibliography::
:style: alpha

However, in the LaTeX/PDF output the list of references will not appear here,
but at the end of the document.
For a possible work-around,
see https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/156.

.. warning::

With ``docutils`` versions 0.18 and 0.19,
the HTML output after the bibliography is broken,
see https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/309.
This problem will be fixed in the next ``docutils`` version
(either 0.19.1 or 0.20).
For an example, see the file ``doc/references.rst``.


Footnote citations
Expand Down
13 changes: 13 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@
latex_show_urls = 'footnote'
latex_show_pagerefs = True

# -- Work-around to get LaTeX References at the same place as HTML --------

# See https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/156

import sphinx.builders.latex.transforms

class DummyTransform(sphinx.builders.latex.transforms.BibliographyTransform):

def run(self, **kwargs):
pass

sphinx.builders.latex.transforms.BibliographyTransform = DummyTransform

# -- Options for EPUB output ----------------------------------------------

# These are just defined to avoid Sphinx warnings related to EPUB:
Expand Down
3 changes: 2 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All of the following content
was generated from Jupyter notebooks,
except for the sections :doc:`a-normal-rst-file`,
:doc:`contributing` and :doc:`version-history`,
:doc:`contributing`, :doc:`references` and :doc:`version-history`,
which were generated from Sphinx's built-in `reStructuredText`__ format.
The sections
:doc:`custom-formats`,
Expand Down Expand Up @@ -39,6 +39,7 @@ __ https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
a-markdown-file
links
contributing
references
version-history

.. only:: html
Expand Down
32 changes: 32 additions & 0 deletions doc/references.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
References
==========

By default, in the LaTeX/PDF output the list of references will not appear here,
but instead at the end of the document.
For a possible work-around (which is also used here)
see https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/156.

The list of references may look something like this:

.. raw:: latex

\begingroup
\def\section#1#2{}
\def\chapter#1#2{}
\begin{thebibliography}{1234}

.. bibliography::
:style: alpha

.. raw:: latex

\end{thebibliography}
\endgroup

.. warning::

With ``docutils`` versions 0.18 and 0.19,
the HTML output after the bibliography is broken,
see https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/309.
This problem will be fixed in the next ``docutils`` version
(either 0.19.1 or 0.20).

0 comments on commit 4df8cb3

Please sign in to comment.