Skip to content

Commit

Permalink
Migrated to PyData Sphinx theme (#299)
Browse files Browse the repository at this point in the history
* Migrated to PyData Sphinx theme and fixed API generation.

* Downgrade theme version to one which is available.

* Bump depricated actions in workflow.

* Prefer a more modern flake8.

* Downgrade flake8 to pre v7.0.0.

* Another go at guessing the correct flake8 version.
  • Loading branch information
MatthewHambley authored Apr 17, 2024
1 parent 07ec96a commit 4649173
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Compiler
Expand Down
11 changes: 11 additions & 0 deletions docs/source/_templates/crown-copyright.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{# Crown copyright is displayed differently to normal. #}
{# Configured from conf.py as per usual. #}
{% if show_copyright and copyright %}
<p class="copyright">
{% if hasdoc('copyright') %}
{% trans path=pathto('copyright'), copyright=copyright|e %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
{% else %}
{% trans copyright=copyright|e %}© Crown Copyright {{ copyright }}.{% endtrans %}
{% endif %}
</p>
{% endif %}
10 changes: 10 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
API Documentation
=================

This API documentation is generated from comments within the source code.

.. autosummary::
:toctree: api
:recursive:

fab
50 changes: 26 additions & 24 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

# -- Project information -----------------------------------------------------

project = 'fab'
copyright = '2023'
project = 'Fab'
copyright = '2024 Met Office. All rights reserved.'
author = 'Fab Team'

# The full version, including alpha/beta/rc tags
Expand Down Expand Up @@ -52,24 +52,35 @@
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# -- Autodoc -----------------------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
autodoc_default_options = {
'members': True,
'show-inheritane': True
}

# ugly
# html_theme = "classic"
autoclass_content = 'both'

# poor contrast between title, h1 & h2
# html_theme = "sphinxdoc"
# html_theme = "sphinx_rtd_theme"
# html_theme = 'python_docs_theme'

# good contrast between title, h1 & h2
# html_theme = 'alabaster'
html_theme = 'sphinx_material'
# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'pydata_sphinx_theme'

html_theme_options = {
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/metomi/fab",
"icon": "fa-brands fa-github"
}
],
"footer_start": ["crown-copyright"],
"footer_center": ["sphinx-version"],
"footer_end": ["theme-version"],
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -93,12 +104,3 @@

# include default values in argument descriptions
typehints_defaults = 'braces-after'

# needed when using material theme
html_sidebars = {
"**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]
}
# needed when not using material theme
# html_sidebars = {
# "**": ["globaltoc.html", "searchbox.html"]
# }
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ See also
writing_config
advanced_config
features
Api Reference <apidoc/modules>
Api Reference <api>
development
glossary
genindex
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ classifiers = [
c-language = ['python-clang']
plots = ['matplotlib']
tests = ['pytest', 'pytest-cov', 'pytest-mock']
checks = ['flake8', 'mypy']
docs = ['sphinx', 'sphinx-material', 'sphinx-autodoc-typehints', 'sphinx-copybutton']
checks = ['flake8>=5.0.4', 'mypy']
docs = ['sphinx',
'pydata-sphinx-theme>=0.13.3',
'sphinx-autodoc-typehints',
'sphinx-copybutton']
dev = ['sci-fab[plots, tests, checks, docs]']

[project.scripts]
Expand Down

0 comments on commit 4649173

Please sign in to comment.