Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add a basic how-to for switching to the new theme. #246

Merged
merged 3 commits into from
Jan 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions source/developers/how-tos/switch-to-the-sphinx-book-theme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
How to Switch to the sphinx-book-theme for Documentation
########################################################

This how-to will help you switch from your existing Sphinx theme to the
sphinx-book-theme for a sphinx documentation project.

Assumptions
***********

.. This section should contain a bulleted list of assumptions you have of the
person who is following the How-to. The assumptions may link to other
how-tos if possible.

* You already have a sphinx documentation project.
feanil marked this conversation as resolved.
Show resolved Hide resolved

* You know how to work with python code.
feanil marked this conversation as resolved.
Show resolved Hide resolved

Steps
*****

.. A task should have 3 - 7 steps. Tasks with more should be broken down into digestible chunks.

#. Update and rebuild your requirements.

#. Find the requirements file that has your documentation requirements in it.

For most projects there will be a ``requirements/docs.in`` file which will
contain your theme as a python requirement. For example if you are using
feanil marked this conversation as resolved.
Show resolved Hide resolved
the deprecated ``edx-sphinx-theme``. You'll see a line with that package
feanil marked this conversation as resolved.
Show resolved Hide resolved
name on it.

#. Remove your old theme(e.g. ``edx-sphinx-theme``) and add a line for the
feanil marked this conversation as resolved.
Show resolved Hide resolved
sphinx-book-theme.
feanil marked this conversation as resolved.
Show resolved Hide resolved

.. code::

- edx-sphinx-theme
+ sphinx-book-theme

#. Run ``make upgrade``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a likelihood that something might go wrong here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect it to go wrong but I think once we have people try it on a few more repos, we can probably integrate feedback if there are common issues.


#. Install your doc requirements.

.. code::

pip install -r requirements/docs.txt # in most cases

#. Update conf.py

Add or update the following
.. code::

import os

html_theme_options = {

"repository_url": TODO: Add a URL Here,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"repository_url": TODO: Add a URL Here,
"repository_url": "https://github.com/openedx/the-name-of-your-repo",

This entry and the next could use some explanation

"repository_branch": TODO: Add the correct branch here,
"path_to_docs": "docs/",
"logo_only": True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 1.0.1 of sphinx-book-theme is complaining about logo_only being an "unsupported theme option". Should this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yea good call I created #345 to fix this.

"home_page_in_toc": True,
"use_repository_button": True,
"use_issues_button": True,
"use_edit_page_button": True,
"extra_footer": """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is complicated, and shouldn't be changed, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

<a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">
<img
alt="Creative Commons License"
style="border-width:0"
src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png">
feanil marked this conversation as resolved.
Show resolved Hide resolved
</a>
<br>
These works by
<a
xmlns:cc="https://creativecommons.org/ns#"
href="https://openedx.org"
property="cc:attributionName"
rel="cc:attributionURL"
>The Center for Reimagining Learning</a>
are licensed under a
<a
rel="license"
href="https://creativecommons.org/licenses/by-sa/4.0/"
>Creative Commons Attribution-ShareAlike 4.0 International License</a>.
"""
}

# Note the logo won't show up properly yet because there is an upstream
# bug in the theme that needs to be fixed first.
# If you'd like you can temporarily copy the logo file to your `_static`
# directory.
html_logo = "https://logos.openedx.org/open-edx-logo-color.png"
html_favicon = "https://logos.openedx.org/open-edx-favicon.ico"

# Set the DJANGO_SETTINGS_MODULE if it's not set.
# Only if your project has a dependency on Django
if not os.environ.get('DJANGO_SETTINGS_MODULE'):
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_utils.test_settings'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might also need some explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more, let me know what you think.


#. Re-build your project and fix any errors.

.. code::

make html # and fix errors until there are no errors.

Once everything is building correctly without errors you should be all set to
make a pull request with your changes!

.. Following the steps, you should add the result and any follow-up tasks needed.

.. seealso::

:doc:`add-sphinx-docs-to-a-repo`