What is Sphinx?
===============
Sphinx lets you generate static web pages that can be hosted on sites such as `Github Pages `_ and `Read the Docs `_.
While there are other tools that can be used to generate documentation, Sphinx is **open source**, popular, and well-supported.
Some use cases for Sphinx include:
.. grid:: 2
:gutter: 4
.. grid-item-card::
:class-header: `sd-bg-secondary sd-text-white sd-text-center`
:material-regular:`dvr;2em` Documenting Code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sphinx can be used to generate documentation from `docstrings `_. For example: Python's `code documentation `_.
.. grid-item-card::
:class-header: `sd-bg-secondary sd-text-white sd-text-center`
:material-regular:`auto_stories;2em` Knowledge Base
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sphinx can also be used more like a wiki, where reference documents can be hosted in an accessible location.
.. grid-item-card::
:class-header: `sd-bg-secondary sd-text-white sd-text-center`
:material-regular:`rss_feed;2em` Blogging
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"Blog-style" posts can be integrated into any Sphinx project using the `ABlog extension `_.
.. grid-item-card::
:class-header: `sd-bg-secondary sd-text-white sd-text-center`
:material-regular:`visibility;2em` Data Visualization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jupyter notebook visualizations can be embedded into Sphinx documentation using the `nbsphinx `_ extension.
.. grid-item-card::
:margin: 4 2 auto auto
:class-header: `sd-bg-secondary sd-text-white sd-text-center`
:text-align: center
:material-regular:`image;2em` Gallery
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can easily throw together a gallery of cards to highlight important features, links, or images. For example, `this site `_.
How do I use Sphinx?
====================
.. admonition:: Why reStructuredText (rST)?
:class: sidebar note
This demo assumes you'll be using rST to write documentation.
While there is `support for Markdown `_, the grammar can be cumbersome when writing complicated :term:`directives`.
Sphinx can be run locally on your laptop to generate HTML files from source code, `Markdown `_, or `reStructredText (rST) `_.
You can also run it remotely on GitHub by adding a post-commit hook to build documentation pushed to a repository. This will be expanded upon in a later tutorial.
.. todo::
Add link to tutorial to build docs in GitHub