|
7 | 7 | import re |
8 | 8 | import sys |
9 | 9 |
|
10 | | -sys.path.append(os.path.abspath('.')) |
11 | | -sys.path.append(os.path.abspath("..")) |
| 10 | +# 3rd party |
| 11 | +from sphinx_pyproject import SphinxConfig |
12 | 12 |
|
13 | | -# this package |
14 | | -from __pkginfo__ import __version__ |
| 13 | +sys.path.append('.') |
15 | 14 |
|
16 | | -github_username = "domdfcoding" |
17 | | -github_repository = "flake8_strftime" |
18 | | -github_url = f"https://github.com/{github_username}/{github_repository}" |
| 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) |
19 | 21 |
|
20 | 22 | rst_prolog = f""".. |pkgname| replace:: flake8_strftime |
21 | 23 | .. |pkgname2| replace:: ``flake8_strftime`` |
22 | 24 | .. |browse_github| replace:: `Browse the GitHub Repository <{github_url}>`__ |
23 | 25 | """ |
24 | 26 |
|
25 | | -author = "Dominic Davis-Foster" |
26 | | -project = "flake8_strftime".replace('_', '-') |
27 | 27 | slug = re.sub(r'\W+', '-', project.lower()) |
28 | | -release = version = __version__ |
29 | | -copyright = "2020-2021 Dominic Davis-Foster" # pylint: disable=redefined-builtin |
30 | | -language = "en" |
31 | | -package_root = "flake8_strftime" |
32 | | - |
33 | | -extensions = [ |
34 | | - "sphinx_toolbox", |
35 | | - "sphinx_toolbox.more_autodoc", |
36 | | - "sphinx_toolbox.more_autosummary", |
37 | | - "sphinx_toolbox.tweaks.param_dash", |
38 | | - "sphinx_toolbox.tweaks.latex_toc", |
39 | | - "sphinx.ext.intersphinx", |
40 | | - "sphinx.ext.mathjax", |
41 | | - "sphinxcontrib.httpdomain", |
42 | | - "sphinxcontrib.extras_require", |
43 | | - "sphinx.ext.todo", |
44 | | - "sphinxemoji.sphinxemoji", |
45 | | - "notfound.extension", |
46 | | - "sphinx_copybutton", |
47 | | - "sphinxcontrib.default_values", |
48 | | - "sphinxcontrib.toctree_plus", |
49 | | - "sphinx_debuginfo", |
50 | | - "seed_intersphinx_mapping", |
51 | | - "sphinx_toolbox.pre_commit", |
52 | | - "sphinx_toolbox.flake8", |
53 | | - ] |
54 | | - |
55 | | -sphinxemoji_style = "twemoji" |
56 | | -todo_include_todos = bool(os.environ.get("SHOW_TODOS", 0)) |
57 | | -gitstamp_fmt = "%d %b %Y" |
| 28 | +release = version = config.version |
58 | 29 |
|
59 | | -templates_path = ["_templates"] |
60 | | -html_static_path = ["_static"] |
61 | | -source_suffix = ".rst" |
62 | | -master_doc = "index" |
63 | | -suppress_warnings = ["image.nonlocal_uri"] |
64 | | -pygments_style = "default" |
| 30 | +todo_include_todos = bool(os.environ.get("SHOW_TODOS", 0)) |
65 | 31 |
|
66 | 32 | intersphinx_mapping = { |
67 | 33 | "python": ("https://docs.python.org/3/", None), |
68 | 34 | "sphinx": ("https://www.sphinx-doc.org/en/stable/", None), |
69 | 35 | } |
70 | 36 |
|
71 | | -html_theme = "furo" |
72 | 37 | html_theme_options = { |
73 | 38 | "light_css_variables": { |
74 | 39 | "toc-title-font-size": "12pt", |
|
81 | 46 | "admonition-font-size": "12pt", |
82 | 47 | }, |
83 | 48 | } |
84 | | -html_theme_path = ["../.."] |
85 | | -html_show_sourcelink = True # True will show link to source |
86 | 49 |
|
87 | 50 | html_context = {} |
88 | 51 | htmlhelp_basename = slug |
|
91 | 54 | man_pages = [("index", slug, project, [author], 1)] |
92 | 55 | texinfo_documents = [("index", slug, project, author, slug, project, "Miscellaneous")] |
93 | 56 |
|
94 | | -toctree_plus_types = { |
95 | | - "class", |
96 | | - "function", |
97 | | - "method", |
98 | | - "data", |
99 | | - "enum", |
100 | | - "flag", |
101 | | - "confval", |
102 | | - "directive", |
103 | | - "role", |
104 | | - "confval", |
105 | | - "protocol", |
106 | | - "typeddict", |
107 | | - "namedtuple", |
108 | | - "exception", |
109 | | - } |
| 57 | +toctree_plus_types = set(config["toctree_plus_types"]) |
110 | 58 |
|
111 | | -add_module_names = False |
112 | | -hide_none_rtype = True |
113 | | -all_typevars = True |
114 | | -overloads_location = "bottom" |
115 | | - |
116 | | - |
117 | | -autodoc_exclude_members = [ # Exclude "standard" methods. |
118 | | - "__dict__", |
119 | | - "__class__", |
120 | | - "__dir__", |
121 | | - "__weakref__", |
122 | | - "__module__", |
123 | | - "__annotations__", |
124 | | - "__orig_bases__", |
125 | | - "__parameters__", |
126 | | - "__subclasshook__", |
127 | | - "__init_subclass__", |
128 | | - "__attrs_attrs__", |
129 | | - "__init__", |
130 | | - "__new__", |
131 | | - "__getnewargs__", |
132 | | - "__abstractmethods__", |
133 | | - "__hash__", |
134 | | - ] |
135 | 59 | autodoc_default_options = { |
136 | 60 | "members": None, # Include all members (methods). |
137 | 61 | "special-members": None, |
138 | 62 | "autosummary": None, |
139 | 63 | "show-inheritance": None, |
140 | | - "exclude-members": ','.join(autodoc_exclude_members), |
| 64 | + "exclude-members": ','.join(config["autodoc_exclude_members"]), |
141 | 65 | } |
| 66 | + |
| 67 | +latex_elements = { |
| 68 | + "printindex": "\\begin{flushleft}\n\\printindex\n\\end{flushleft}", |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | +def setup(app): |
| 73 | + # 3rd party |
| 74 | + from sphinx_toolbox.latex import better_header_layout |
| 75 | + |
| 76 | + app.connect("config-inited", lambda app, config: better_header_layout(config)) |
0 commit comments