Skip to content

Commit a93df74

Browse files
committed
Improve docs layout with the LaTeX builder.
1 parent a2668f4 commit a93df74

File tree

11 files changed

+191
-250
lines changed

11 files changed

+191
-250
lines changed

coverage_pyver_pragma/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ def evaluate_exclude(expression: str) -> bool:
6565
6666
.. versionadded:: 0.2.4
6767
68-
|
69-
7068
:param expression:
7169
"""
7270

coverage_pyver_pragma/grammar.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
#
33
# grammar.py
4-
"""
4+
r"""
55
.. versionadded:: 0.2.0
66
77
As with ``coverage.py``, lines are marked with comments in the form::
@@ -50,6 +50,9 @@
5050
5151
If the current platform cannot be determined all strings are treated as :py:obj:`True`.
5252
53+
.. raw:: latex
54+
55+
\clearpage
5356
5457
.. py:data:: IMPLEMENTATION_TAG
5558
@@ -68,11 +71,11 @@
6871
Examples
6972
-----------
7073
71-
ignore if the Python version is less than or equal to 3.7::
74+
Ignore if the Python version is less than or equal to 3.7::
7275
7376
# pragma: no cover (<=py37)
7477
75-
ignore if running on Python 3.9::
78+
Ignore if running on Python 3.9::
7679
7780
# pragma: no cover (py39)
7881
@@ -92,6 +95,10 @@
9295
9396
# pragma: no cover (!CPython)
9497
98+
.. raw:: latex
99+
100+
\clearpage
101+
95102
API Reference
96103
----------------
97104

doc-source/_templates/sidebar/navigation.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

doc-source/conf.py

Lines changed: 15 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,90 +5,19 @@
55
# stdlib
66
import os
77
import re
8+
import sys
89

910
# 3rd party
1011
from sphinx_pyproject import SphinxConfig
1112

12-
config = SphinxConfig()
13-
14-
github_username = "python-coincidence"
15-
github_repository = "coverage_pyver_pragma"
16-
author = "Dominic Davis-Foster"
17-
project = "coverage-pyver-pragma"
18-
copyright = "2020-2021 Dominic Davis-Foster"
19-
language = "en"
20-
package_root = "coverage_pyver_pragma"
21-
extensions = [
22-
"sphinx_toolbox",
23-
"sphinx_toolbox.more_autodoc",
24-
"sphinx_toolbox.more_autosummary",
25-
"sphinx_toolbox.documentation_summary",
26-
"sphinx_toolbox.tweaks.param_dash",
27-
"sphinx_toolbox.tweaks.latex_toc",
28-
"sphinx.ext.intersphinx",
29-
"sphinx.ext.mathjax",
30-
"sphinxcontrib.httpdomain",
31-
"sphinxcontrib.extras_require",
32-
"sphinx.ext.todo",
33-
"sphinxemoji.sphinxemoji",
34-
"notfound.extension",
35-
"sphinx_copybutton",
36-
"sphinxcontrib.default_values",
37-
"sphinxcontrib.toctree_plus",
38-
"sphinx_debuginfo",
39-
"seed_intersphinx_mapping",
40-
]
41-
sphinxemoji_style = "twemoji"
42-
gitstamp_fmt = "%d %b %Y"
43-
templates_path = ["_templates"]
44-
html_static_path = ["_static"]
45-
source_suffix = ".rst"
46-
master_doc = "index"
47-
suppress_warnings = ["image.nonlocal_uri"]
48-
pygments_style = "default"
49-
html_theme = "furo"
50-
html_theme_path = ["../.."]
51-
html_show_sourcelink = True
52-
toctree_plus_types = [
53-
"class",
54-
"confval",
55-
"data",
56-
"directive",
57-
"enum",
58-
"exception",
59-
"flag",
60-
"function",
61-
"method",
62-
"namedtuple",
63-
"protocol",
64-
"role",
65-
"typeddict",
66-
]
67-
add_module_names = False
68-
hide_none_rtype = True
69-
all_typevars = True
70-
overloads_location = "bottom"
71-
documentation_summary = "Plugin for Coverage.py to selectively ignore branches depending on the Python version."
72-
autodoc_exclude_members = [
73-
"__dict__",
74-
"__class__",
75-
"__dir__",
76-
"__weakref__",
77-
"__module__",
78-
"__annotations__",
79-
"__orig_bases__",
80-
"__parameters__",
81-
"__subclasshook__",
82-
"__init_subclass__",
83-
"__attrs_attrs__",
84-
"__init__",
85-
"__new__",
86-
"__getnewargs__",
87-
"__abstractmethods__",
88-
"__hash__",
89-
]
90-
91-
github_url = f"https://github.com/{github_username}/{github_repository}"
13+
sys.path.append('.')
14+
15+
config = SphinxConfig(globalns=globals())
16+
project = config["project"]
17+
author = config["author"]
18+
documentation_summary = config.description
19+
20+
github_url = "https://github.com/{github_username}/{github_repository}".format_map(config)
9221

9322
rst_prolog = f""".. |pkgname| replace:: coverage_pyver_pragma
9423
.. |pkgname2| replace:: ``coverage_pyver_pragma``
@@ -126,12 +55,16 @@
12655
man_pages = [("index", slug, project, [author], 1)]
12756
texinfo_documents = [("index", slug, project, author, slug, project, "Miscellaneous")]
12857

129-
toctree_plus_types = set(toctree_plus_types)
58+
toctree_plus_types = set(config["toctree_plus_types"])
13059

13160
autodoc_default_options = {
13261
"members": None, # Include all members (methods).
13362
"special-members": None,
13463
"autosummary": None,
13564
"show-inheritance": None,
136-
"exclude-members": ','.join(autodoc_exclude_members),
65+
"exclude-members": ','.join(config["autodoc_exclude_members"]),
66+
}
67+
68+
latex_elements = {
69+
"fncychap": "\\usepackage[Bjarne]{fncychap}\n\\ChNameAsIs\n\\ChTitleAsIs\n",
13770
}

doc-source/configuration.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
=================
2+
Configuration
3+
=================
4+
5+
.. versionadded:: 0.3.0
6+
7+
When using Coverage.py's `reporting commands <https://coverage.readthedocs.io/en/coverage-5.5/cmd.html?highlight=report#coverage-summary-coverage-report>`_
8+
it may be desirable to generate a report for a different Python version / implementation / platform to the current one.
9+
For instance, you are generating a report from a ``.coverage`` file produced on PyPy 3.6 on Windows, but you are running CPython 3.8 on Linux.
10+
11+
``coverage_pyver_pragma`` provides three environment variables which can be used to set the target version and platform.
12+
13+
.. envvar:: COV_PYTHON_VERSION
14+
15+
Sets the Python version. Must be in the form :file:`{<major>}.{<minor>}`.
16+
17+
Defaults to the output of :func:`'.'.join(platform.python_version_tuple()[:2]) <platform.python_version_tuple>`.
18+
19+
**Example:**
20+
21+
.. prompt:: bash
22+
23+
COV_PYTHON_VERSION=3.6 coverage report
24+
25+
.. envvar:: COV_PLATFORM
26+
27+
Sets the Python platform.
28+
Must be a string which matches the output of :func:`platform.system` on the desired platform.
29+
30+
Defaults to the output of :func:`platform.system`.
31+
32+
**Example:**
33+
34+
.. prompt:: bash
35+
36+
COV_PLATFORM=Windows coverage report
37+
38+
.. envvar:: COV_PYTHON_IMPLEMENTATION
39+
40+
Sets the Python implementation.
41+
Must be a string which matches the output of
42+
:func:`platform.python_implementation` with the desired implementation.
43+
44+
Defaults to the output of :func:`platform.python_implementation`.
45+
46+
**Example:**
47+
48+
.. prompt:: bash
49+
50+
COV_PYTHON_IMPLEMENTATION=PyPy coverage report
51+
52+
If you generate your coverage reports through `tox <https://tox.readthedocs.io/en/latest/>`_
53+
you should configure `passenv <https://tox.readthedocs.io/en/latest/config.html?highlight=setenv#conf-passenv>`_
54+
to ensure the environment variables are passed through:
55+
56+
.. code-block:: ini
57+
58+
[testenv]
59+
passenv =
60+
COV_PYTHON_VERSION
61+
COV_PLATFORM
62+
COV_PYTHON_IMPLEMENTATION

doc-source/contributing.rst

Lines changed: 0 additions & 72 deletions
This file was deleted.

doc-source/index.rst

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,11 @@ coverage_pyver_pragma
122122

123123
.. end shields
124124
125-
Installation
126-
---------------
125+
Contents
126+
----------
127127

128-
.. start installation
128+
.. html-section::
129129

130-
.. installation:: coverage_pyver_pragma
131-
:pypi:
132-
:github:
133-
:anaconda:
134-
:conda-channels: conda-forge, domdfcoding
135-
136-
.. end installation
137130

138131
.. toctree::
139132
:hidden:
@@ -142,18 +135,21 @@ Installation
142135

143136
.. toctree::
144137
:maxdepth: 3
145-
:caption: Documentation
146138

147139
installation
140+
configuration
148141
syntax
149142
api
143+
Source
150144

151-
.. toctree::
152-
:maxdepth: 3
153-
:caption: Contributing
154145

155-
contributing
156-
Source
146+
.. sidebar-links::
147+
:caption: Links
148+
:github:
149+
:pypi: coverage_pyver_pragma
150+
151+
Contributing Guide <https://contributing-to-coincidence.readthedocs.io/en/latest/>
152+
157153

158154
.. start links
159155

0 commit comments

Comments
 (0)