Skip to content

Commit f198ce0

Browse files
authored
Merge pull request #5893 from readthedocs/davidfischer/guides-restructure
Rework on documentation guides
2 parents e574168 + ba42548 commit f198ce0

File tree

5 files changed

+126
-44
lines changed

5 files changed

+126
-44
lines changed

docs/guides/adding-custom-css.rst

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,79 @@
1-
Adding Custom CSS or JavaScript to a Sphinx Project
2-
===================================================
1+
Adding Custom CSS or JavaScript to Sphinx Documentation
2+
=======================================================
33

4-
The easiest way to add custom stylesheets or scripts, and ensure that the files
5-
are added in a way that allows for overriding of existing styles or scripts, is
6-
to add these files using a ``conf.py`` Sphinx extension. Inside your
7-
``conf.py``, if a function ``setup(app)`` exists, Sphinx will call this function
8-
as a normal extension during application setup.
4+
.. meta::
5+
:description lang=en:
6+
How to add additional CSS stylesheets or JavaScript files
7+
to your Sphinx documentation
8+
to override your Sphinx theme or add interactivity with JavaScript.
99

10-
For example, if a custom stylesheet exists at ``_static/css/custom.css``, a
11-
``conf.py`` extension can be written to add this file to the list of
12-
stylesheets::
10+
Adding additional CSS or JavaScript files to your Sphinx documentation
11+
can let you customize the look and feel of your docs
12+
or add additional functionality.
13+
For example, with a small snippet of CSS,
14+
your documentation could use a custom font or have a different background color.
1315

14-
def setup(app):
15-
app.add_stylesheet('css/custom.css')
16+
If your custom stylesheet is ``_static/css/custom.css``,
17+
you can add that CSS file to the documentation using the
18+
Sphinx option `html_css_files`_::
1619

17-
Using an extension to add the stylesheet allows for the file to be added to the
18-
list of stylesheets later in the Sphinx setup process, making overriding parts
19-
of the Read the Docs theme possible.
20+
## conf.py
2021

21-
The same method can be used to add additional scripts that might override
22-
previously initialized scripts::
22+
# These folders are copied to the documentation's HTML output
23+
html_static_path = ['_static']
2324

24-
def setup(app):
25-
app.add_javascript('js/custom.js')
25+
# These paths are either relative to html_static_path
26+
# or fully qualified paths (eg. https://...)
27+
html_css_files = [
28+
'css/custom.css',
29+
]
30+
31+
32+
A similar approach can be used to add JavaScript files::
33+
34+
html_js_files = [
35+
'js/custom.js',
36+
]
37+
38+
39+
40+
.. _html_css_files: https://www.sphinx-doc.org/page/usage/configuration.html#confval-html_css_files
41+
42+
.. note::
43+
44+
The Sphinx HTML options ``html_css_files`` and ``html_js_files``
45+
where added in Sphinx 1.8.
46+
Unless you have a good reason to use an older version,
47+
you are strongly encouraged to upgrade.
48+
Sphinx is almost entirely backwards compatible.
49+
50+
51+
Overriding or replacing a theme's stylesheet
52+
--------------------------------------------
53+
54+
The above approach is preferred for adding additional stylesheets or JavaScript,
55+
but it is also possible to completely replace a Sphinx theme's stylesheet
56+
with your own stylesheet.
57+
58+
If your replacement stylesheet exists at ``_static/css/yourtheme.css``,
59+
you can replace your theme's CSS file by setting ``html_style`` in your ``conf.py``::
60+
61+
## conf.py
62+
63+
html_style = 'css/yourtheme.css'
64+
65+
If you only need to override a few styles on the theme,
66+
you can include the theme's normal CSS using the CSS
67+
`@import rule <https://developer.mozilla.org/en-US/docs/Web/CSS/@import>`_ .
68+
69+
.. code-block:: css
70+
71+
/** css/yourtheme.css **/
72+
73+
/* This line is theme specific - it includes the base theme CSS */
74+
@import '../alabaster.css'; /* for Alabaster */
75+
/*@import 'theme.css'; /* for the Read the Docs theme */
76+
77+
body {
78+
/* ... */
79+
}

docs/guides/custom-404-page.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Use custom ``404 Not Found`` page on my project
2-
===============================================
1+
Use a Custom ``404 Not Found`` Page on my Project
2+
=================================================
33

44
If you want your project to use a custom page for not found pages instead of the "Maze Found" default one,
55
you can put a ``404.html`` at the top level of your project's HTML output.

docs/guides/index.rst

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
11
Guides
22
======
33

4-
These guides will help walk you through the usage of Read the Docs.
4+
These guides will help walk you through specific use cases
5+
related to Read the Docs itself, documentation tools like Sphinx and MkDocs
6+
and how to write successful documentation.
57

68

9+
Sphinx & MkDocs how-to guides
10+
-----------------------------
11+
12+
These guides will help you get the most out of your documentation authoring tool
13+
whether that is Sphinx or MkDocs.
14+
15+
.. toctree::
16+
:maxdepth: 1
17+
18+
adding-custom-css
19+
custom-404-page
20+
manage-translations
21+
mkdocs-old-versions
22+
pdf-non-ascii-languages
23+
remove-edit-buttons
24+
vcs
25+
26+
27+
Read the Docs how-to guides
28+
---------------------------
29+
30+
These guides will help you customize or tune aspects of the Read the Docs build environment.
31+
732
.. toctree::
8-
:maxdepth: 1
9-
:glob:
33+
:maxdepth: 1
1034

11-
*
35+
build-notifications
36+
build-using-too-many-resources
37+
canonical
38+
conda
39+
environment-variables
40+
feature-flags
41+
google-analytics
42+
sitemaps
43+
specifying-dependencies
44+
wipe-environment

docs/guides/mkdocs-old-versions.rst

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
Keep Building Docs With Old Version Of MkDocs
2-
=============================================
1+
Building With Pre-1.0 Versions Of MkDocs
2+
========================================
33

4-
Recent changes to ``mkdocs`` forced us to `upgrade the default version installed`_ by Read the Docs and this may be a breaking change for your documentation.
4+
Recent changes to ``mkdocs`` forced us to `upgrade the default version installed`_ by Read the Docs
5+
and this may be a breaking change for your documentation.
56

67
.. _upgrade the default version installed: https://github.com/readthedocs/readthedocs.org/pull/4041
78

@@ -15,8 +16,8 @@ In case your builds are failing because of a ``mkdocs`` issue,
1516
you may want to follow one of the following solutions depending on the case.
1617

1718

18-
Pin mkdocs to the previous version
19-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
Pin MkDocs to an older version
20+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021

2122
Before Read the Docs upgraded its default version installed, ``mkdocs==0.15.0`` was used.
2223
To make your project continue using this version you will need to create a ``requirements.txt`` file with this content::
@@ -27,21 +28,15 @@ To make your project continue using this version you will need to create a ``req
2728
mkdocs-bootswatch==0.1.0
2829
markdown>=2.3.1,<2.5
2930

30-
.. note::
31-
32-
Most of the breaking changes where introduced in ``mkdocs==0.17``,
33-
so you may want to test only pinning ``mkdocs`` to ``mkdocs<0.17``
34-
and check if your docs keep building successfully.
35-
3631

3732
More detailed information about how to specify dependencies can be found :ref:`here <guides/specifying-dependencies:Specifying Dependencies>`.
3833

3934

40-
Upgrade your custom theme to be compatible with newer mkdocs versions
35+
Upgrade your custom theme to be compatible with later MkDocs versions
4136
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4237

43-
It is possible that event your build passes your documentation doesn't look correct.
44-
This may be because the new ``mkdocs==0.17.3`` version installed by Read the Docs introduced some breaking changes on the structure of the theme.
38+
It is possible that your build passes but your documentation doesn't look correct.
39+
This may be because newer MkDocs versions installed by Read the Docs introduced some breaking changes on the structure of the theme.
4540

4641
You should check the `mkdocs' Custom Theme documentation`_ to upgrade your custom theme and make it compatible with the new version.
4742

@@ -51,7 +46,7 @@ You should check the `mkdocs' Custom Theme documentation`_ to upgrade your custo
5146
Upgrade how extension arguments are defined
5247
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5348

54-
``mkdocs`` has changed the way that ``markdown_extensions`` are defined and you may need to upgrade it.
49+
MkDocs has changed the way that ``markdown_extensions`` are defined and you may need to upgrade it.
5550
If you where passing arguments to the extension by defining them between brackets (``toc(permalink=true)``) in your ``mkdocs.yaml`` you may need to upgrade it to the new way.
5651

5752
For example, this definition:

docs/guides/pdf-non-ascii-languages.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Build PDF format for non-ASCII languages
2-
========================================
1+
Sphinx PDFs with Unicode
2+
========================
33

4-
Sphinx offers different `LaTeX engines`_ that support Unicode characters and non-ASCII languages,
5-
like Japanese or Chinese.
4+
Sphinx offers different `LaTeX engines`_ that have better support for Unicode characters
5+
and non-European languages like Japanese or Chinese.
66
By default Sphinx uses ``pdflatex``,
77
which does not have good support for Unicode characters and may make the PDF builder fail.
88

0 commit comments

Comments
 (0)