Welcome to Sphinx Cheat Sheet ============================= Add code extract : ================== .. code-block:: none .. code-block:: Code must be one indent more that the code-block tag, and separated by a blank line. This very text is an example. Replace by "none" to avoid color highlighting. .. _my-reference-label: Add in-line code extract ======================== .. code-block:: none ``this will show as an in-line code extract`` This won't. Add a local content table of content ==================================== .. code-block:: none .. contents:: :local: Add an image ============ .. code-block:: none .. image:: image.png Add an image with link to see it full size ========================================== .. code-block:: none .. image:: _static/image.png :target: _static/image.png Add a simple table ================== .. code-block:: none =========================== =========================== Test title 1 Test Title 2 =========================== =========================== Row 1 Col 1 Row 1 Col 2 Row 2 Col 1 Row 2 Col 2 Row 3 Col 1 Row 3 Col 2 =========================== =========================== Add a numbered list =================== .. code-block:: none #. Something #. Something else #. Another thing #. etc... Add a bullet list ================= .. code-block:: none * Something * Something else * Another thing * etc... External link ============= .. code-block:: none `Link text `_ example : `CNN `_ Cross-referencing arbitrary locations inside the document ========================================================== Place the following code on top of the target : .. code-block:: none .. _my-reference-label: The use ``:ref:`` like this : .. code-block:: none ...bla bla bla, see :ref:`my-reference-label`. Example : ...bla bla bla, see :ref:`my-reference-label`. Render math formulas as images (uses LaTeX) =========================================== - Install a latex distrib (Windows : Miktex for example) - In ``conf.py`` add the corresponding extension : .. code-block:: python # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.imgmath' ] - Add Latex-like math formulas like this : .. code-block:: rst .. math:: (a + b)^2 &= (a + b)(a + b) \\ &= a^2 + 2ab + b^2 *Result :* .. math:: (a + b)^2 &= (a + b)(a + b) \\ &= a^2 + 2ab + b^2 .. code-block:: rst .. math:: :nowrap: \begin{eqnarray} y & = & ax^2 + bx + c \\ f(x) & = & x^2 + 2xy + y^2 \end{eqnarray} *Result :* .. math:: :nowrap: \begin{eqnarray} y & = & ax^2 + bx + c \\ f(x) & = & x^2 + 2xy + y^2 \end{eqnarray} .. code-block:: rst .. math:: e^{i\pi} + 1 = 0 :label: euler *Result :* .. math:: e^{i\pi} + 1 = 0 :label: euler .. code-block:: rst Euler's identity, equation :eq:`euler`, was elected one of the most beautiful mathematical formulas. *Result :* Euler's identity, equation :eq:`euler`, was elected one of the most beautiful mathematical formulas. Inline equations : .. code-block:: rst Since Pythagoras, we know that :math:`a^2 + b^2 = c^2`. *Result :* Since Pythagoras, we know that :math:`a^2 + b^2 = c^2`.