Skip to content

Commit 4f3403e

Browse files
DOC/Sphinx-documentation config file: Improve comments, fix typos (#3573)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent a0e4226 commit 4f3403e

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

doc/conf.py

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pygmt.sphinx_gallery import PyGMTScraper
1212
from sphinx_gallery.sorting import ExampleTitleSortKey, ExplicitOrder
1313

14-
# Dictionary for dependency name and minimum required version.
14+
# Dictionary for dependency name and minimum required versions
1515
requirements = {
1616
Requirement(requirement).name: str(Requirement(requirement).specifier)
1717
for requirement in importlib.metadata.requires("pygmt")
@@ -50,7 +50,8 @@
5050

5151
# Auto-generate header anchors with MyST parser
5252
myst_heading_anchors = 4
53-
# reference: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
53+
# MyST extensions
54+
# Reference: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
5455
myst_enable_extensions = [
5556
"attrs_inline", # Allow inline attributes after images
5657
"colon_fence", # Allow code fences using colons
@@ -61,26 +62,25 @@
6162
"requires": requirements,
6263
}
6364

64-
# MyST-NB configurations.
65+
# Configure MyST-NB
6566
# Reference: https://myst-nb.readthedocs.io/en/latest/configuration.html
66-
nb_render_markdown_format = "myst" # The format to use for text/markdown rendering
67+
nb_render_markdown_format = "myst" # Format for text/markdown rendering
6768

68-
# Make the list of returns arguments and attributes render the same as the
69-
# parameters list
69+
# Render the return argument and attribute lists in the same way as the parameter lists
7070
napoleon_use_rtype = False
7171
napoleon_use_ivar = True
7272

73-
# sphinx_auto_typehints
73+
# Configure sphinx_auto_typehints
7474
typehints_defaults = "comma"
7575

76-
# configure links to GMT docs
76+
# Define links to GMT docs
7777
extlinks = {
7878
"gmt-docs": ("https://docs.generic-mapping-tools.org/6.5/%s", None),
7979
"gmt-term": ("https://docs.generic-mapping-tools.org/6.5/gmt.conf#term-%s", "%s"),
8080
"gmt-datasets": ("https://www.generic-mapping-tools.org/remote-datasets/%s", None),
8181
}
8282

83-
# intersphinx configuration
83+
# Configure intersphinx
8484
intersphinx_mapping = {
8585
"contextily": ("https://contextily.readthedocs.io/en/stable/", None),
8686
"geopandas": ("https://geopandas.org/en/stable/", None),
@@ -93,22 +93,22 @@
9393
"xyzservices": ("https://xyzservices.readthedocs.io/en/stable", None),
9494
}
9595

96-
# options for sphinx-copybutton
97-
# https://sphinx-copybutton.readthedocs.io
96+
# Configure sphinx-copybutton
97+
# Reference: https://sphinx-copybutton.readthedocs.io
9898
copybutton_prompt_text = r">>> |\.\.\. "
9999
copybutton_prompt_is_regexp = True
100100
copybutton_only_copy_prompt_lines = True
101101
copybutton_remove_prompts = True
102102

103103
sphinx_gallery_conf = {
104-
# path to your examples scripts
104+
# Set paths to your examples scripts
105105
"examples_dirs": [
106106
"../examples/gallery",
107107
"../examples/tutorials",
108108
"../examples/get_started",
109109
"../examples/projections",
110110
],
111-
# path where to save gallery generated examples
111+
# Set paths where to save the generated examples
112112
"gallery_dirs": ["gallery", "tutorials", "get_started", "projections"],
113113
"subsection_order": ExplicitOrder(
114114
[
@@ -136,31 +136,29 @@
136136
"filename_pattern": r"\.py",
137137
# Remove the "Download all examples" button from the top level gallery
138138
"download_all_examples": False,
139-
# Sort gallery example by file name instead of number of lines (default)
139+
# Sort gallery examples by the file names instead of number of lines [Default]
140140
"within_subsection_order": ExampleTitleSortKey,
141-
# directory where function granular galleries are stored
141+
# Directory where function granular galleries are stored
142142
"backreferences_dir": "api/generated/backreferences",
143-
# Modules for which function level galleries are created. In
144-
# this case sphinx_gallery and numpy in a tuple of strings.
145-
"doc_module": "pygmt",
143+
# Modules for which function level galleries are created (given as tuple of strings)
144+
"doc_module": ("pygmt",),
146145
# Insert links to documentation of objects in the examples
147146
"reference_url": {"pygmt": None},
148147
"image_scrapers": (PyGMTScraper(),),
149-
# Removes configuration comments from scripts
148+
# Remove configuration comments from scripts
150149
"remove_config_comments": True,
151-
# Disable "nested_sections" (default is True), to
152-
# generate only a single index file for the whole gallery.
153-
# This is a new feature up on Sphinx-Gallery 0.11.0.
150+
# Disable "nested_sections" [Default is True], to generate only a single index file
151+
# for the whole gallery. This is a new feature up on Sphinx-Gallery 0.11.0.
154152
"nested_sections": False,
155153
}
156154

157-
# Sphinx project configuration
155+
# Configure Sphinx project
158156
templates_path = ["_templates"]
159157
exclude_patterns = [
160158
"_build",
161159
"**.ipynb_checkpoints",
162160
# Workaround from https://github.com/executablebooks/MyST-NB/issues/363 to prevent
163-
# myst-nb from parsing the .ipynb and .py files generated by sphinx-gallery.
161+
# MyST-NB from parsing the .ipynb and .py files generated by Sphinx-Gallery.
164162
"gallery/**.ipynb",
165163
"tutorials/**.ipynb",
166164
"get_started/**.ipynb",
@@ -173,7 +171,7 @@
173171

174172
source_suffix = ".rst"
175173
needs_sphinx = "1.8"
176-
# The encoding of source files.
174+
# Encoding of source files
177175
source_encoding = "utf-8-sig"
178176
root_doc = "index"
179177

@@ -183,11 +181,11 @@
183181
copyright = f"2017-{year}, The PyGMT Developers" # noqa: A001
184182
if len(__version__.split("+")) > 1 or __version__ == "unknown":
185183
version = "dev"
186-
# Set base_url for stable version
184+
# Set base URL for dev version
187185
html_baseurl = "https://pygmt.org/dev/"
188186
else:
189187
version = __version__
190-
# Set base_url for dev version
188+
# Set base URL for stable version
191189
html_baseurl = "https://pygmt.org/latest/"
192190
release = __version__
193191

@@ -205,7 +203,7 @@
205203
html_show_sphinx = False
206204
html_show_copyright = True
207205

208-
# Theme config
206+
# Configure theme
209207
html_theme = "sphinx_rtd_theme"
210208
html_theme_options = {}
211209
repository = "GenericMappingTools/pygmt"
@@ -237,8 +235,7 @@
237235
repository_url,
238236
),
239237
],
240-
# Custom variables to enable "Improve this page"" and "Download notebook"
241-
# links
238+
# Custom variables to enable "Improve this page"" and "Download notebook" links
242239
"doc_path": "doc",
243240
"galleries": sphinx_gallery_conf["gallery_dirs"],
244241
"gallery_dir": dict(

0 commit comments

Comments
 (0)