|
| 1 | +.. meta:: |
| 2 | + :author: Adam Korn |
| 3 | + :title: Sphinx README - Generate README.rst That Renders Beautifully on GitHub, PyPi, GitLab, BitBucket |
| 4 | + :description: Sphinx extension to generate reStructuredText README.rst files that render beautifully on GitHub, PyPi, GitLab, BitBucket |
| 5 | + |
| 6 | +.. only:: pypi |
| 7 | + |
| 8 | + Sphinx README - Generate Beautiful README.rst for GitHub, PyPi, GitLab, BitBucket |
| 9 | + -------------------------------------------------------------------------------------- |
| 10 | + |
| 11 | + .. image:: _static/logo_transparent.png |
| 12 | + :alt: Sphinx README: Generate Beautiful reStructuredText README.rst for GitHub, PyPi, GitLab, BitBucket |
| 13 | + :align: center |
| 14 | + :width: 25% |
| 15 | + |
| 16 | +.. raw:: html |
| 17 | + |
| 18 | + <div align="center"> |
| 19 | + |
| 20 | +.. only:: readme |
| 21 | + |
| 22 | + .. image:: _static/logo_readme.png |
| 23 | + :alt: Sphinx README: Generate Beautiful reStructuredText README.rst for GitHub, PyPi, GitLab, BitBucket |
| 24 | + :align: center |
| 25 | + :width: 25% |
| 26 | + |
| 27 | +.. only:: html |
| 28 | + |
| 29 | + .. image:: _static/logo_html.png |
| 30 | + :alt: Sphinx README: Generate Beautiful reStructuredText README.rst for GitHub, PyPi, GitLab, BitBucket |
| 31 | + :align: center |
| 32 | + :width: 25% |
| 33 | + |
| 34 | +.. only:: readme |
| 35 | + |
| 36 | + .. raw:: html |
| 37 | + |
| 38 | + <h1>Sphinx README</h1> |
| 39 | + |
| 40 | + |
| 41 | +.. only:: html |
| 42 | + |
| 43 | + .. raw:: html |
| 44 | + |
| 45 | + <span class="h1">Sphinx README</span> |
| 46 | + |
| 47 | + |
| 48 | +A Sphinx extension to generate ``README.rst`` files that render beautifully on GitHub, PyPi, GitLab, BitBucket |
| 49 | + |
| 50 | +.. only:: readme or pypi |
| 51 | + |
| 52 | + .. |RTD| replace:: **Explore the docs »** |
| 53 | + .. _RTD: https://sphinx-readme.readthedocs.io/en/latest/ |
| 54 | + |
| 55 | + |RTD|_ |
| 56 | + |
| 57 | +.. only:: pypi |
| 58 | + |
| 59 | + | |
| 60 | +
|
| 61 | +.. image:: https://img.shields.io/pypi/v/sphinx-readme?color=eb5202 |
| 62 | + :target: https://pypi.org/project/sphinx-readme |
| 63 | + :alt: PyPI Project for Sphinx README: Generate Beautiful reStructuredText README.rst for GitHub, PyPi, GitLab, BitBucket |
| 64 | + |
| 65 | +.. image:: https://img.shields.io/badge/GitHub-sphinx--readme-4f1abc |
| 66 | + :target: https://github.com/tdkorn/sphinx-readme |
| 67 | + :alt: GitHub Repository for Sphinx README: Generate Beautiful reStructuredText README.rst for GitHub, PyPi, GitLab, BitBucket |
| 68 | + |
| 69 | +.. image:: https://static.pepy.tech/personalized-badge/sphinx-readme?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads |
| 70 | + :target: https://pepy.tech/project/sphinx-readme |
| 71 | + :alt: Downloads for Sphinx README |
| 72 | + |
| 73 | +.. image:: https://readthedocs.org/projects/sphinx-readme/badge/?version=latest |
| 74 | + :target: https://sphinx-readme.readthedocs.io/en/latest/?badge=latest |
| 75 | + :alt: Documentation for Sphinx README: Generate Beautiful reStructuredText README.rst for GitHub, PyPi, GitLab, BitBucket |
| 76 | + |
| 77 | +.. image:: https://img.shields.io/github/actions/workflow/status/TDKorn/sphinx-readme/tests.yml?label=build&color=33ce57 |
| 78 | + :target: https://github.com/TDKorn/sphinx-readme/actions/workflows/tests.yml |
| 79 | + :alt: Build Status |
| 80 | + |
| 81 | +.. image:: https://codecov.io/gh/TDKorn/sphinx-readme/graph/badge.svg?token=RZCUCGIU0Q |
| 82 | + :target: https://codecov.io/gh/TDKorn/sphinx-readme |
| 83 | + :alt: Code Coverage |
| 84 | + |
| 85 | +.. raw:: html |
| 86 | + |
| 87 | + </div> |
| 88 | + |
| 89 | +| |
| 90 | +
|
| 91 | +About Sphinx README |
| 92 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 93 | + |
| 94 | +.. admonition:: What's Sphinx README? |
| 95 | + :class: about |
| 96 | + |
| 97 | + ``sphinx_readme`` is a ``reStructuredText`` parser that uses Sphinx |
| 98 | + to generate ``rst`` files that render beautifully on |
| 99 | + GitHub, PyPi, GitLab, and BitBucket. |
| 100 | + |
| 101 | + |
| 102 | +.. rubric:: With ``sphinx_readme``, there's no need to rewrite your ``README.rst`` as a ``README.md`` file |
| 103 | + |
| 104 | +Files generated by ``sphinx_readme`` have nearly identical appearance and functionality |
| 105 | +as ``html`` builds, including :mod:`sphinx.ext.autodoc` cross-references! |
| 106 | + |
| 107 | +.. only:: pypi |
| 108 | + |
| 109 | + | |
| 110 | +
|
| 111 | +.. image:: _static/demo/demo.gif |
| 112 | + :alt: Demonstration of how reStructuredText README.rst files generated by Sphinx README render on GitHub, PyPi, GitLab, BitBucket |
| 113 | + :width: 75% |
| 114 | + |
| 115 | + |
| 116 | +📋 Features |
| 117 | +~~~~~~~~~~~~ |
| 118 | + |
| 119 | +``sphinx_readme`` adds support for the following ``sphinx`` and ``docutils`` directives and features: |
| 120 | + |
| 121 | +* :mod:`sphinx.ext.autodoc` cross-references (``:mod:``, ``:class:``, ``:meth:``, ``:func:``, and ``:attr:``) |
| 122 | +* Standard cross-reference roles (``:doc:`` and ``:ref:``) |
| 123 | +* Generic and Specific Admonitions |
| 124 | +* Only directives |
| 125 | +* Toctrees |
| 126 | +* Rubrics |
| 127 | +* Images |
| 128 | + |
| 129 | + |
| 130 | +⚙ Installation |
| 131 | +~~~~~~~~~~~~~~~~ |
| 132 | + |
| 133 | +Install using pip:: |
| 134 | + |
| 135 | + pip install sphinx-readme |
| 136 | + |
| 137 | + |
| 138 | +Add the extension to your ``conf.py``: |
| 139 | + |
| 140 | +.. code-block:: python |
| 141 | +
|
| 142 | + extensions = [ |
| 143 | + 'sphinx_readme', |
| 144 | + ] |
| 145 | +
|
| 146 | +
|
| 147 | +
|
| 148 | +🔧 Configuration |
| 149 | +~~~~~~~~~~~~~~~~~ |
| 150 | + |
| 151 | +.. only:: html or latex |
| 152 | + |
| 153 | + Please see :doc:`configuration/configuring` |
| 154 | + |
| 155 | + |
| 156 | +.. only:: readme or pypi |
| 157 | + |
| 158 | + Please see :doc:`configuration/configuring` for full documentation on configuration variables |
| 159 | + |
| 160 | + |
| 161 | + Mandatory ``conf.py`` Values |
| 162 | + ================================== |
| 163 | + |
| 164 | + :confval:`html_context` |
| 165 | + A dictionary containing info about your repository (:external+sphinx:confval:`html_context`) |
| 166 | + |
| 167 | + **Type:** ``dict`` |
| 168 | + |
| 169 | + * At minimum, the username and repository name must be specified |
| 170 | + * Please see :ref:`HTML Context Settings <rtd:guides/edit-source-links-sphinx:github>` |
| 171 | + to determine the correct dictionary keys for your hosting platform |
| 172 | + |
| 173 | + |
| 174 | + | |
| 175 | +
|
| 176 | + :confval:`html_baseurl` |
| 177 | + The base URL which points to the root of the HTML documentation (:confval:`sphinx:html_baseurl`) |
| 178 | + |
| 179 | + **Type:** ``str`` |
| 180 | + |
| 181 | + |
| 182 | + | |
| 183 | +
|
| 184 | + :confval:`readme_src_files` |
| 185 | + An individual/list of ``rst`` source files to parse, or a dictionary of source files mapped to output files |
| 186 | + |
| 187 | + **Type:** ``Union[str, List[str], Dict[str,str]]`` |
| 188 | + |
| 189 | + .. important:: Filepaths should be specified relative to the source directory |
| 190 | + and :confval:`output directory <readme_out_dir>` |
| 191 | + |
| 192 | + | |
| 193 | +
|
| 194 | + :confval:`readme_docs_url_type` |
| 195 | + The documentation source to link to when resolving :mod:`~.sphinx.ext.autodoc` cross-references |
| 196 | + |
| 197 | + **Type:** ``str`` |
| 198 | + |
| 199 | + Must be either ``"code"`` or ``"html"`` |
| 200 | + |
| 201 | + * ``"code"``: uses :mod:`sphinx.ext.linkcode` to replace references with links to highlighted source code |
| 202 | + |
| 203 | + **Example**: :meth:`~.parse_intersphinx_nodes` |
| 204 | + |
| 205 | + |
| 206 | + * ``"html"``: replaces references with links to HTML documentation entries |
| 207 | + |
| 208 | + **Example**: |parse_intersphinx_nodes_html|_ |
| 209 | + |
| 210 | + .. note:: If set to ``code``, non-external :code:`:attr:` cross-references will not be replaced with links |
| 211 | + |
| 212 | + * Instead, they'll be replaced with ``inline literals`` or left as is |
| 213 | + * Please see :confval:`readme_replace_attrs` and :confval:`readme_inline_markup` |
| 214 | + |
| 215 | + |
| 216 | + .. |parse_intersphinx_nodes_html| replace:: ``parse_intersphinx_nodes()`` |
| 217 | + .. _parse_intersphinx_nodes_html: http://sphinx-readme.readthedocs.io/en/latest/parser.html#sphinx_readme.parser.READMEParser.parse_intersphinx_nodes |
| 218 | + |
| 219 | + |
| 220 | + .. include:: configuration/sample_conf.rst |
| 221 | + |
| 222 | + |
| 223 | + 📚 Documentation |
| 224 | + ~~~~~~~~~~~~~~~~ |
| 225 | + |
| 226 | + Full documentation can be found on |docs|_ |
| 227 | + |
| 228 | + |
| 229 | + .. |docs| replace:: ``ReadTheDocs`` |
| 230 | + .. _docs: https://sphinx-readme.readthedocs.io/en/latest |
0 commit comments