coherent.docs 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ [pipx.run]
2
+ coherent.docs = coherent.docs.core:run
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 <copyright holders>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: coherent.docs
3
+ Version: 1.0.0
4
+ Author-Email: Jason R. Coombs <jaraco@jaraco.com>
5
+ Summary: API and narrative docs builder for the /coherent-oss/system
6
+ Requires-Python: >= 3.8
7
+ Requires-Dist: coherent.build
8
+ Requires-Dist: pip-run
9
+ Requires-Dist: sphinx>=3.5
10
+ Requires-Dist: jaraco.packaging>=9.3
11
+ Requires-Dist: rst.linker>=1.9
12
+ Requires-Dist: furo
13
+ Requires-Dist: sphinx-lint
14
+ Provides-Extra: test
15
+ Provides-Extra: doc
16
+ Project-URL: Source, https://github.com/coherent-oss/coherent.docs
17
+ Description-Content-Type: text/markdown
18
+ Classifier: Development Status :: 5 - Production/Stable
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ License-Expression: MIT
23
+
24
+ [![](https://img.shields.io/pypi/v/coherent.docs)](https://pypi.org/project/coherent.docs)
25
+
26
+ ![](https://img.shields.io/pypi/pyversions/coherent.docs)
27
+
28
+ [![](https://github.com/coherent-oss/coherent.docs/actions/workflows/main.yml/badge.svg)](https://github.com/coherent-oss/coherent.docs/actions?query=workflow%3A%22tests%22)
29
+
30
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
31
+
32
+ [![Coherent Software Development System](https://img.shields.io/badge/coherent%20system-informational)](https://github.com/coherent-oss/system)
33
+
@@ -0,0 +1,10 @@
1
+ [![](https://img.shields.io/pypi/v/coherent.docs)](https://pypi.org/project/coherent.docs)
2
+
3
+ ![](https://img.shields.io/pypi/pyversions/coherent.docs)
4
+
5
+ [![](https://github.com/coherent-oss/coherent.docs/actions/workflows/main.yml/badge.svg)](https://github.com/coherent-oss/coherent.docs/actions?query=workflow%3A%22tests%22)
6
+
7
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
8
+
9
+ [![Coherent Software Development System](https://img.shields.io/badge/coherent%20system-informational)](https://github.com/coherent-oss/system)
10
+
@@ -0,0 +1,16 @@
1
+ """
2
+ Tool for orchestrating documentation builds using Sphinx.
3
+
4
+ >>> __name__
5
+ 'coherent.docs'
6
+ """
7
+
8
+ __requires__ = [
9
+ 'coherent.build',
10
+ 'pip-run',
11
+ 'sphinx >= 3.5',
12
+ 'jaraco.packaging >= 9.3',
13
+ 'rst.linker >= 1.9',
14
+ 'furo',
15
+ 'sphinx-lint',
16
+ ]
@@ -0,0 +1,3 @@
1
+ from . import core
2
+
3
+ __name__ == '__main__' and core.run()
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ extensions = [
4
+ 'sphinx.ext.autodoc',
5
+ 'jaraco.packaging.sphinx',
6
+ ]
7
+
8
+ master_doc = "index"
9
+ html_theme = "furo"
10
+
11
+ # Be strict about any broken references
12
+ nitpicky = True
13
+ nitpick_ignore: list[tuple[str, str]] = []
14
+
15
+ # Include Python intersphinx mapping to prevent failures
16
+ # jaraco/skeleton#51
17
+ extensions += ['sphinx.ext.intersphinx']
18
+ intersphinx_mapping = {
19
+ 'python': ('https://docs.python.org/3', None),
20
+ }
21
+
22
+ # Preserve authored syntax for defaults
23
+ autodoc_preserve_defaults = True
24
+
25
+ # Add support for linking usernames, PyPI projects, Wikipedia pages
26
+ github_url = 'https://github.com/'
27
+ extlinks = {
28
+ 'user': (f'{github_url}%s', '@%s'),
29
+ 'pypi': ('https://pypi.org/project/%s', '%s'),
30
+ 'wiki': ('https://wikipedia.org/wiki/%s', '%s'),
31
+ }
32
+ extensions += ['sphinx.ext.extlinks']
33
+
34
+ # local
@@ -0,0 +1,132 @@
1
+ import contextlib
2
+ import importlib.resources
3
+ import os
4
+ import pathlib
5
+ import re
6
+ import subprocess
7
+ import sys
8
+
9
+ import pip_run.deps
10
+ import pip_run.launch
11
+ from coherent.build import bootstrap, discovery
12
+
13
+ AUTOMODULE_TMPL = """\
14
+
15
+ .. automodule:: {mod}
16
+ :members:
17
+ :undoc-members:
18
+ :show-inheritance:
19
+ """
20
+
21
+
22
+ def find_modules(package_name: str, root: pathlib.Path = pathlib.Path()) -> list[str]:
23
+ """
24
+ Find all public modules in the package using the essential layout.
25
+
26
+ >>> find_modules('my.pkg', pathlib.Path('/nonexistent'))
27
+ []
28
+ """
29
+
30
+ def to_module(path):
31
+ parts = path.relative_to(root).with_suffix('').parts
32
+ if parts[-1] == '__init__':
33
+ parts = parts[:-1]
34
+ return '.'.join((package_name,) + parts) if parts else package_name
35
+
36
+ return sorted(
37
+ filter(
38
+ lambda m: not re.search(r'\._', m),
39
+ map(to_module, root.rglob('*.py')),
40
+ ),
41
+ key=lambda m: (m.count('.'), m),
42
+ )
43
+
44
+
45
+ def make_modules_rst(modules: list[str]) -> str:
46
+ """
47
+ Generate the automodule directives for each public module.
48
+ """
49
+ return ''.join(AUTOMODULE_TMPL.format(mod=m) for m in modules)
50
+
51
+
52
+ def make_index_rst(package_name: str, modules: list[str]) -> str:
53
+ """
54
+ Generate ``index.rst`` content from the template plus
55
+ ``automodule`` directives for each public module.
56
+ """
57
+ template = (
58
+ importlib.resources
59
+ .files(__package__)
60
+ .joinpath('index.tmpl.rst')
61
+ .read_text('utf-8')
62
+ )
63
+ return template.format(modules=make_modules_rst(modules))
64
+
65
+
66
+ def build_env(target, *, orig=os.environ):
67
+ """
68
+ Build the environment for invoking sphinx, inserting the installed
69
+ packages path onto PYTHONPATH.
70
+
71
+ # TODO: consolidate with coherent.test and other similar helpers.
72
+ >>> env = build_env('foo', orig=dict(PYTHONPATH='bar'))
73
+ >>> env['PYTHONPATH'].replace(os.pathsep, ':')
74
+ 'foo:bar'
75
+ """
76
+ overlay = dict(
77
+ PYTHONPATH=pip_run.launch._path_insert(
78
+ orig.get('PYTHONPATH', ''), os.fspath(target)
79
+ ),
80
+ PYTHONSAFEPATH='1',
81
+ )
82
+ return {**orig, **overlay}
83
+
84
+
85
+ def load_conf_py():
86
+ return importlib.resources.files(__package__).joinpath('conf.py').read_text('utf-8')
87
+
88
+
89
+ @contextlib.contextmanager
90
+ def configure_docs(package_name: str):
91
+ """
92
+ Create the ``docs/`` directory and generate ``conf.py`` and ``index.rst``
93
+ (only if they do not already exist), yielding for the sphinx build, then
94
+ cleaning up any files we created.
95
+ """
96
+ docs = pathlib.Path('docs')
97
+ docs.mkdir(exist_ok=True)
98
+ modules = find_modules(package_name)
99
+ with (
100
+ bootstrap.assured(docs / 'conf.py', load_conf_py),
101
+ bootstrap.assured(
102
+ docs / 'index.rst', lambda: make_index_rst(package_name, modules)
103
+ ),
104
+ ):
105
+ yield
106
+
107
+
108
+ @contextlib.contextmanager
109
+ def project_on_path():
110
+ """
111
+ Install the target project plus doc build dependencies in an ephemeral
112
+ environment and yield the installation home path.
113
+ """
114
+ deps = pip_run.deps.load('--editable', '.[doc]')
115
+ with bootstrap.write_pyproject(), deps as home:
116
+ yield home
117
+
118
+
119
+ def run():
120
+ package_name = discovery.best_name()
121
+ with project_on_path() as home:
122
+ with configure_docs(package_name):
123
+ cmd = [
124
+ sys.executable,
125
+ '-m',
126
+ 'sphinx',
127
+ '-b',
128
+ 'html',
129
+ 'docs',
130
+ 'build/html',
131
+ ]
132
+ raise SystemExit(subprocess.call(cmd, env=build_env(home)))
@@ -0,0 +1,19 @@
1
+ Welcome to |project| documentation!
2
+ ===================================
3
+
4
+ .. sidebar-links::
5
+ :home:
6
+ :pypi:
7
+ :releases:
8
+
9
+ .. toctree::
10
+ :maxdepth: 1
11
+
12
+ {modules}
13
+
14
+ Indices and tables
15
+ ==================
16
+
17
+ * :ref:`genindex`
18
+ * :ref:`modindex`
19
+ * :ref:`search`
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["flit-core >=3.11, <4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "coherent.docs"
7
+ version = "1.0.0"
8
+ description = "API and narrative docs builder for the /coherent-oss/system"
9
+ readme = "README.md"
10
+ requires-python = ">= 3.8"
11
+ dependencies = ["coherent.build", "pip-run", "sphinx>=3.5", "jaraco.packaging>=9.3", "rst.linker>=1.9", "furo", "sphinx-lint"]
12
+ classifiers = ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"]
13
+ license = "MIT"
14
+
15
+ [[project.authors]]
16
+ name = "Jason R. Coombs"
17
+ email = "jaraco@jaraco.com"
18
+
19
+ [project.urls]
20
+ Source = "https://github.com/coherent-oss/coherent.docs"
21
+
22
+ [project.entry-points."pipx.run"]
23
+ "coherent.docs" = "coherent.docs.core:run"
24
+
25
+ [project.scripts]