Skip to content

Commit 4e7e28b

Browse files
seismanweiji14
andauthored
Check and lint sphinx configuration file doc/conf.py (#630)
* Remove the _build/html directory * Remove unused import * Use html_css_files to include custom CSS files (needs Sphinx>=1.8) The old way (the `setup()` function) is difficult to understand. * Fix linting errors in doc/conf.py * Check and lint doc/conf.py * Disable the "no-name-in-module" lint error Co-authored-by: Wei Ji <[email protected]>
1 parent 593ca1a commit 4e7e28b

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ PYTEST_ARGS=--cov=$(PROJECT) --cov-config=../.coveragerc \
66
--doctest-modules -v --mpl --mpl-results-path=results \
77
--pyargs ${PYTEST_EXTRA}
88
BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples
9-
FLAKE8_FILES=$(PROJECT) setup.py
10-
LINT_FILES=$(PROJECT) setup.py
9+
FLAKE8_FILES=$(PROJECT) setup.py doc/conf.py
10+
LINT_FILES=$(PROJECT) setup.py doc/conf.py
1111

1212
help:
1313
@echo "Commands:"

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ help:
2121
@echo " doctest run all doctests embedded in the documentation (if enabled)"
2222

2323
clean:
24-
rm -rf $(BUILDDIR)/html/*
24+
rm -rf $(BUILDDIR)/html
2525
rm -rf $(BUILDDIR)/doctrees
2626
rm -rf $(BUILDDIR)/linkcheck
2727
rm -rf modules

doc/conf.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# -*- coding: utf-8 -*-
2-
import sys
3-
import os
4-
import glob
5-
import shutil
2+
"""
3+
Sphinx documentation configuration file.
4+
"""
5+
# pylint: disable=invalid-name
6+
67
import datetime
7-
import sphinx_rtd_theme
8-
import sphinx_gallery
9-
from sphinx_gallery.sorting import FileNameSortKey, ExplicitOrder
8+
from sphinx_gallery.sorting import ( # pylint: disable=no-name-in-module
9+
FileNameSortKey,
10+
ExplicitOrder,
11+
)
1012
from pygmt import __version__, __commit__
1113
from pygmt.sphinx_gallery import PyGMTScraper
1214

@@ -91,14 +93,15 @@
9193
templates_path = ["_templates"]
9294
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
9395
source_suffix = ".rst"
96+
needs_sphinx = "1.8"
9497
# The encoding of source files.
9598
source_encoding = "utf-8-sig"
9699
master_doc = "index"
97100

98101
# General information about the project
99102
year = datetime.date.today().year
100103
project = "PyGMT"
101-
copyright = "2017-{}, The PyGMT Developers.".format(year)
104+
copyright = f"2017-{year}, The PyGMT Developers." # pylint: disable=redefined-builtin
102105
if len(__version__.split("+")) > 1 or __version__ == "unknown":
103106
version = "dev"
104107
else:
@@ -118,6 +121,7 @@
118121
html_logo = ""
119122
html_favicon = "_static/favicon.png"
120123
html_static_path = ["_static"]
124+
html_css_files = ["style.css"]
121125
html_extra_path = []
122126
pygments_style = "default"
123127
add_function_parentheses = False
@@ -129,28 +133,29 @@
129133
html_theme = "sphinx_rtd_theme"
130134
html_theme_options = {}
131135
repository = "GenericMappingTools/pygmt"
132-
commit_link = f'<a href="https://github.com/GenericMappingTools/pygmt/commit/{ __commit__ }">{ __commit__[:7] }</a>'
136+
repository_url = "https://github.com/GenericMappingTools/pygmt"
137+
commit_link = f'<a href="{repository_url}/commit/{ __commit__ }">{ __commit__[:7] }</a>'
133138
html_context = {
134139
"menu_links": [
135140
(
136141
'<i class="fa fa-users fa-fw"></i> Contributing',
137-
"https://github.com/GenericMappingTools/pygmt/blob/master/CONTRIBUTING.md",
142+
f"{repository_url}/blob/master/CONTRIBUTING.md",
138143
),
139144
(
140145
'<i class="fa fa-gavel fa-fw"></i> Code of Conduct',
141-
"https://github.com/GenericMappingTools/pygmt/blob/master/CODE_OF_CONDUCT.md",
146+
f"{repository_url}/blob/master/CODE_OF_CONDUCT.md",
142147
),
143148
(
144149
'<i class="fa fa-book fa-fw"></i> License',
145-
"https://github.com/GenericMappingTools/pygmt/blob/master/LICENSE.txt",
150+
f"{repository_url}/blob/master/LICENSE.txt",
146151
),
147152
(
148153
'<i class="fa fa-comment fa-fw"></i> Contact',
149154
"https://forum.generic-mapping-tools.org",
150155
),
151156
(
152157
'<i class="fa fa-github fa-fw"></i> Source Code',
153-
"https://github.com/GenericMappingTools/pygmt",
158+
repository_url,
154159
),
155160
],
156161
# Custom variables to enable "Improve this page"" and "Download notebook"
@@ -164,8 +169,3 @@
164169
"github_version": "master",
165170
"commit": commit_link,
166171
}
167-
168-
169-
# Load the custom CSS files (needs sphinx >= 1.6 for this to work)
170-
def setup(app):
171-
app.add_stylesheet("style.css")

0 commit comments

Comments
 (0)