stouputils 1.18.6__py3-none-any.whl → 1.19.0__py3-none-any.whl
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.
- stouputils/applications/automatic_docs.py +44 -62
- stouputils/applications/automatic_docs.pyi +6 -12
- {stouputils-1.18.6.dist-info → stouputils-1.19.0.dist-info}/METADATA +5 -4
- {stouputils-1.18.6.dist-info → stouputils-1.19.0.dist-info}/RECORD +6 -6
- {stouputils-1.18.6.dist-info → stouputils-1.19.0.dist-info}/WHEEL +1 -1
- {stouputils-1.18.6.dist-info → stouputils-1.19.0.dist-info}/entry_points.txt +0 -0
|
@@ -68,8 +68,6 @@ Example of GitHub Actions workflow:
|
|
|
68
68
|
# Imports
|
|
69
69
|
import os
|
|
70
70
|
import shutil
|
|
71
|
-
import subprocess
|
|
72
|
-
import sys
|
|
73
71
|
from collections.abc import Callable
|
|
74
72
|
from typing import Any
|
|
75
73
|
|
|
@@ -79,7 +77,7 @@ from ..io import clean_path, json_dump, super_open
|
|
|
79
77
|
from ..print import info
|
|
80
78
|
|
|
81
79
|
# Constants
|
|
82
|
-
REQUIREMENTS: list[str] = ["
|
|
80
|
+
REQUIREMENTS: list[str] = ["myst_parser"]
|
|
83
81
|
""" List of requirements for automatic_docs to work. """
|
|
84
82
|
|
|
85
83
|
# Functions
|
|
@@ -185,6 +183,12 @@ copybutton_selector = ":not(.prompt) > div.highlight pre"
|
|
|
185
183
|
templates_path: list[str] = ["_templates"]
|
|
186
184
|
exclude_patterns: list[str] = []
|
|
187
185
|
|
|
186
|
+
# Allow both .rst and .md (MyST) sources
|
|
187
|
+
source_suffix = {{
|
|
188
|
+
".rst": "restructuredtext",
|
|
189
|
+
".md": "markdown",
|
|
190
|
+
}}
|
|
191
|
+
|
|
188
192
|
# HTML output options
|
|
189
193
|
html_theme: str = "{html_theme}"
|
|
190
194
|
html_static_path: list[str] = ["_static"]
|
|
@@ -205,7 +209,6 @@ html_theme_options: dict[str, Any] = {{
|
|
|
205
209
|
"github_repo": github_repo,
|
|
206
210
|
"github_version": "main",
|
|
207
211
|
"conf_py_path": "/docs/source/",
|
|
208
|
-
"source_suffix": [".rst", ".md"],
|
|
209
212
|
"default_mode": "dark",
|
|
210
213
|
}
|
|
211
214
|
|
|
@@ -318,23 +321,7 @@ def get_versions_from_github(github_user: str, github_repo: str, recent_minor_ve
|
|
|
318
321
|
version_list = ["latest"]
|
|
319
322
|
return version_list
|
|
320
323
|
|
|
321
|
-
def
|
|
322
|
-
""" Convert markdown content to RST format.
|
|
323
|
-
|
|
324
|
-
Args:
|
|
325
|
-
markdown_content (str): Markdown content
|
|
326
|
-
|
|
327
|
-
Returns:
|
|
328
|
-
str: RST content
|
|
329
|
-
"""
|
|
330
|
-
if not markdown_content:
|
|
331
|
-
return ""
|
|
332
|
-
|
|
333
|
-
# Convert markdown to RST and return it
|
|
334
|
-
import m2r2 # type: ignore
|
|
335
|
-
return m2r2.convert(markdown_content) # type: ignore
|
|
336
|
-
|
|
337
|
-
def generate_index_rst(
|
|
324
|
+
def generate_index_md(
|
|
338
325
|
readme_path: str,
|
|
339
326
|
index_path: str,
|
|
340
327
|
project: str,
|
|
@@ -343,11 +330,14 @@ def generate_index_rst(
|
|
|
343
330
|
get_versions_function: Callable[[str, str, int], list[str]] = get_versions_from_github,
|
|
344
331
|
recent_minor_versions: int = 2,
|
|
345
332
|
) -> None:
|
|
346
|
-
""" Generate index.
|
|
333
|
+
""" Generate `index.md` (MyST) from README.md content.
|
|
334
|
+
|
|
335
|
+
This keeps the README content as Markdown (no conversion) and uses the MyST
|
|
336
|
+
`toctree` directive to include module docs.
|
|
347
337
|
|
|
348
338
|
Args:
|
|
349
339
|
readme_path (str): Path to the README.md file
|
|
350
|
-
index_path (str): Path where index.
|
|
340
|
+
index_path (str): Path where index.md should be created
|
|
351
341
|
project (str): Name of the project
|
|
352
342
|
github_user (str): GitHub username
|
|
353
343
|
github_repo (str): GitHub repository name
|
|
@@ -358,50 +348,44 @@ def generate_index_rst(
|
|
|
358
348
|
with open(readme_path, encoding="utf-8") as f:
|
|
359
349
|
readme_content: str = f.read()
|
|
360
350
|
|
|
361
|
-
# Generate version selector
|
|
362
|
-
version_selector: str = "\n\n**Versions**: "
|
|
363
|
-
|
|
364
|
-
# Get versions from GitHub
|
|
351
|
+
# Generate version selector (markdown links)
|
|
365
352
|
version_list: list[str] = get_versions_function(github_user, github_repo, recent_minor_versions)
|
|
366
|
-
|
|
367
|
-
# Create version links
|
|
368
353
|
version_links: list[str] = []
|
|
369
354
|
for version in version_list:
|
|
370
355
|
if version == "latest":
|
|
371
|
-
version_links.append("
|
|
356
|
+
version_links.append("[latest](../latest/)")
|
|
372
357
|
else:
|
|
373
|
-
version_links.append(f"
|
|
374
|
-
version_selector
|
|
358
|
+
version_links.append(f"[v{version}](../v{version}/)")
|
|
359
|
+
version_selector: str = "\n\n**Versions**: " + ", ".join(version_links)
|
|
375
360
|
|
|
376
|
-
#
|
|
361
|
+
# Module documentation toctree (MyST)
|
|
377
362
|
project_module: str = project.lower()
|
|
378
363
|
module_docs: str = f"""
|
|
379
|
-
|
|
380
|
-
|
|
364
|
+
```{{toctree}}
|
|
365
|
+
:maxdepth: 10
|
|
381
366
|
|
|
382
|
-
|
|
367
|
+
modules/{project_module}
|
|
368
|
+
```
|
|
383
369
|
"""
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
# Convert markdown to RST
|
|
390
|
-
rst_content: str = f"""
|
|
391
|
-
✨ Welcome to {project.capitalize()} Documentation ✨
|
|
392
|
-
{'=' * 100}
|
|
370
|
+
|
|
371
|
+
# Build final markdown content
|
|
372
|
+
md_content: str = f"""
|
|
373
|
+
# ✨ Welcome to {project.capitalize()} Documentation ✨
|
|
374
|
+
|
|
393
375
|
{version_selector}
|
|
394
376
|
|
|
395
|
-
{
|
|
377
|
+
{readme_content}
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## Module Documentation
|
|
396
382
|
|
|
397
|
-
📖 Module Documentation
|
|
398
|
-
{'-' * 100}
|
|
399
383
|
{module_docs}
|
|
400
384
|
"""
|
|
401
385
|
|
|
402
|
-
# Write the
|
|
386
|
+
# Write the Markdown file
|
|
403
387
|
with open(index_path, "w", encoding="utf-8") as f:
|
|
404
|
-
f.write(
|
|
388
|
+
f.write(md_content)
|
|
405
389
|
|
|
406
390
|
def generate_documentation(
|
|
407
391
|
source_dir: str,
|
|
@@ -418,9 +402,8 @@ def generate_documentation(
|
|
|
418
402
|
build_dir (str): Build directory
|
|
419
403
|
"""
|
|
420
404
|
# Generate module documentation using sphinx-apidoc
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
"-m", "sphinx.ext.apidoc",
|
|
405
|
+
from sphinx.ext.apidoc import main as sphinx_apidoc_main
|
|
406
|
+
sphinx_apidoc_main([
|
|
424
407
|
"-o", modules_dir,
|
|
425
408
|
"-f", "-e", "-M",
|
|
426
409
|
"--no-toc",
|
|
@@ -428,17 +411,16 @@ def generate_documentation(
|
|
|
428
411
|
"--implicit-namespaces",
|
|
429
412
|
"--module-first",
|
|
430
413
|
project_dir,
|
|
431
|
-
]
|
|
414
|
+
])
|
|
432
415
|
|
|
433
416
|
# Build HTML documentation
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
"-m", "sphinx",
|
|
417
|
+
from sphinx.cmd.build import main as sphinx_build_main
|
|
418
|
+
sphinx_build_main([
|
|
437
419
|
"-b", "html",
|
|
438
420
|
"-a",
|
|
439
421
|
source_dir,
|
|
440
422
|
build_dir,
|
|
441
|
-
]
|
|
423
|
+
])
|
|
442
424
|
|
|
443
425
|
def generate_redirect_html(filepath: str) -> None:
|
|
444
426
|
""" Generate HTML content for redirect page.
|
|
@@ -478,7 +460,7 @@ def update_documentation(
|
|
|
478
460
|
recent_minor_versions: int = 2,
|
|
479
461
|
|
|
480
462
|
get_versions_function: Callable[[str, str, int], list[str]] = get_versions_from_github,
|
|
481
|
-
generate_index_function: Callable[..., None] =
|
|
463
|
+
generate_index_function: Callable[..., None] = generate_index_md,
|
|
482
464
|
generate_docs_function: Callable[..., None] = generate_documentation,
|
|
483
465
|
generate_redirect_function: Callable[[str], None] = generate_redirect_html,
|
|
484
466
|
get_conf_content_function: Callable[..., str] = get_sphinx_conf_content
|
|
@@ -501,7 +483,7 @@ def update_documentation(
|
|
|
501
483
|
recent_minor_versions (int): Number of recent minor versions to show all patches for. Defaults to 2
|
|
502
484
|
|
|
503
485
|
get_versions_function (Callable[[str, str, int], list[str]]): Function to get versions from GitHub
|
|
504
|
-
generate_index_function (Callable[..., None]): Function to generate index.
|
|
486
|
+
generate_index_function (Callable[..., None]): Function to generate index.md
|
|
505
487
|
generate_docs_function (Callable[..., None]): Function to generate documentation
|
|
506
488
|
generate_redirect_function (Callable[[str], None]): Function to create redirect file
|
|
507
489
|
get_conf_content_function (Callable[..., str]): Function to get Sphinx conf.py content
|
|
@@ -573,9 +555,9 @@ a:hover {
|
|
|
573
555
|
}
|
|
574
556
|
""")
|
|
575
557
|
|
|
576
|
-
# Generate index.
|
|
558
|
+
# Generate index.md from README.md (use MyST instead of converting to RST)
|
|
577
559
|
readme_path: str = f"{root_path}/README.md"
|
|
578
|
-
index_path: str = f"{source_dir}/index.
|
|
560
|
+
index_path: str = f"{source_dir}/index.md"
|
|
579
561
|
generate_index_function(
|
|
580
562
|
readme_path=readme_path,
|
|
581
563
|
index_path=index_path,
|
|
@@ -44,21 +44,15 @@ def get_versions_from_github(github_user: str, github_repo: str, recent_minor_ve
|
|
|
44
44
|
\tReturns:
|
|
45
45
|
\t\tlist[str]: List of versions, with 'latest' as first element
|
|
46
46
|
\t"""
|
|
47
|
-
def
|
|
48
|
-
"""
|
|
47
|
+
def generate_index_md(readme_path: str, index_path: str, project: str, github_user: str, github_repo: str, get_versions_function: Callable[[str, str, int], list[str]] = ..., recent_minor_versions: int = 2) -> None:
|
|
48
|
+
""" Generate `index.md` (MyST) from README.md content.
|
|
49
49
|
|
|
50
|
-
\
|
|
51
|
-
\t
|
|
52
|
-
|
|
53
|
-
\tReturns:
|
|
54
|
-
\t\tstr: RST content
|
|
55
|
-
\t"""
|
|
56
|
-
def generate_index_rst(readme_path: str, index_path: str, project: str, github_user: str, github_repo: str, get_versions_function: Callable[[str, str, int], list[str]] = ..., recent_minor_versions: int = 2) -> None:
|
|
57
|
-
""" Generate index.rst from README.md content.
|
|
50
|
+
\tThis keeps the README content as Markdown (no conversion) and uses the MyST
|
|
51
|
+
\t`toctree` directive to include module docs.
|
|
58
52
|
|
|
59
53
|
\tArgs:
|
|
60
54
|
\t\treadme_path (str): Path to the README.md file
|
|
61
|
-
\t\tindex_path (str): Path where index.
|
|
55
|
+
\t\tindex_path (str): Path where index.md should be created
|
|
62
56
|
\t\tproject (str): Name of the project
|
|
63
57
|
\t\tgithub_user (str): GitHub username
|
|
64
58
|
\t\tgithub_repo (str): GitHub repository name
|
|
@@ -99,7 +93,7 @@ def update_documentation(root_path: str, project: str, project_dir: str = '', au
|
|
|
99
93
|
\t\trecent_minor_versions (int): Number of recent minor versions to show all patches for. Defaults to 2
|
|
100
94
|
|
|
101
95
|
\t\tget_versions_function (Callable[[str, str, int], list[str]]): Function to get versions from GitHub
|
|
102
|
-
\t\tgenerate_index_function (Callable[..., None]): Function to generate index.
|
|
96
|
+
\t\tgenerate_index_function (Callable[..., None]): Function to generate index.md
|
|
103
97
|
\t\tgenerate_docs_function (Callable[..., None]): Function to generate documentation
|
|
104
98
|
\t\tgenerate_redirect_function (Callable[[str], None]): Function to create redirect file
|
|
105
99
|
\t\tget_conf_content_function (Callable[..., str]): Function to get Sphinx conf.py content
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: stouputils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.19.0
|
|
4
4
|
Summary: Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more.
|
|
5
5
|
Keywords: utilities,tools,helpers,development,python
|
|
6
6
|
Author: Stoupy51
|
|
@@ -26,7 +26,6 @@ Requires-Dist: tensorflow ; extra == 'data-science'
|
|
|
26
26
|
Requires-Dist: scikit-learn ; extra == 'data-science'
|
|
27
27
|
Requires-Dist: pywavelets ; extra == 'data-science'
|
|
28
28
|
Requires-Dist: mypy ; extra == 'docs'
|
|
29
|
-
Requires-Dist: m2r2 ; extra == 'docs'
|
|
30
29
|
Requires-Dist: myst-parser ; extra == 'docs'
|
|
31
30
|
Requires-Dist: sphinx-copybutton ; extra == 'docs'
|
|
32
31
|
Requires-Dist: sphinx-design ; extra == 'docs'
|
|
@@ -54,9 +53,11 @@ Stouputils is a collection of utility modules designed to simplify and enhance t
|
|
|
54
53
|
It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers.<br>
|
|
55
54
|
Start now by installing the package: `pip install stouputils`.<br>
|
|
56
55
|
|
|
57
|
-
<a href="https://colab.research.google.com/drive/1mJ-KL-zXzIk1oKDxO6FC1SFfm-BVKG-P?usp=sharing" target="_blank" rel="noopener noreferrer" style="text-decoration: none;"
|
|
56
|
+
<a href="https://colab.research.google.com/drive/1mJ-KL-zXzIk1oKDxO6FC1SFfm-BVKG-P?usp=sharing" target="_blank" rel="noopener noreferrer" style="text-decoration: none;">
|
|
57
|
+
<div class="admonition" style="padding-bottom: 1rem;">
|
|
58
58
|
📖 <b>Want to see examples?</b> Check out our <u>Google Colab notebook</u> with practical usage examples!
|
|
59
|
-
</div
|
|
59
|
+
</div>
|
|
60
|
+
</a>
|
|
60
61
|
|
|
61
62
|
## 🚀 Project File Tree
|
|
62
63
|
<html>
|
|
@@ -7,8 +7,8 @@ stouputils/all_doctests.py,sha256=jQ7HXWoj2VTUbsu8eBq7EiW9mbx-_yXycdpS1fD8Tro,65
|
|
|
7
7
|
stouputils/all_doctests.pyi,sha256=R3FRKaQv3sTZbxLvvsChHZZKygVMhmL6pqrYYLqvZCg,2017
|
|
8
8
|
stouputils/applications/__init__.py,sha256=dbjwZt8PZF043KoJSItqCpH32FtRxN5sgV-8Q2b1l10,457
|
|
9
9
|
stouputils/applications/__init__.pyi,sha256=DTYq2Uqq1uLzCMkFByjRqdtREA-9SaQnp4QpgmCEPFg,56
|
|
10
|
-
stouputils/applications/automatic_docs.py,sha256=
|
|
11
|
-
stouputils/applications/automatic_docs.pyi,sha256=
|
|
10
|
+
stouputils/applications/automatic_docs.py,sha256=piYkrF4_Sg3h9Le3vB7Ni7GmU7zhIDcvhyrm-OGCax8,20123
|
|
11
|
+
stouputils/applications/automatic_docs.pyi,sha256=sBzcz1V98hyGLKRe8h9S6X_uXMQL798yjCTmERNQt14,6121
|
|
12
12
|
stouputils/applications/upscaler/__init__.py,sha256=8vrca93OYu5GQJrZO1GvnAbptzyhu_L0DnP3M9unlA0,1142
|
|
13
13
|
stouputils/applications/upscaler/__init__.pyi,sha256=VSp6Tq09ATCTdfnjhbDnu7lblaLLGbCNi-E22jYxa88,67
|
|
14
14
|
stouputils/applications/upscaler/config.py,sha256=3WHJv6fznM03nWpdvy72OheuJvNgOZfHH4GEjyRpnZU,5559
|
|
@@ -156,7 +156,7 @@ stouputils/typing.py,sha256=TwvxrvxhBRkyHkoOpfyXebN13M3xJb8MAjKXiNIWjew,2205
|
|
|
156
156
|
stouputils/typing.pyi,sha256=U2UmFZausMYpnsUQROQE2JOwHcjx2hKV0rJuOdR57Ew,1341
|
|
157
157
|
stouputils/version_pkg.py,sha256=Jsp-s03L14DkiZ94vQgrlQmaxApfn9DC8M_nzT1SJLk,7014
|
|
158
158
|
stouputils/version_pkg.pyi,sha256=QPvqp1U3QA-9C_CC1dT9Vahv1hXEhstbM7x5uzMZSsQ,755
|
|
159
|
-
stouputils-1.
|
|
160
|
-
stouputils-1.
|
|
161
|
-
stouputils-1.
|
|
162
|
-
stouputils-1.
|
|
159
|
+
stouputils-1.19.0.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
160
|
+
stouputils-1.19.0.dist-info/entry_points.txt,sha256=tx0z9VOnE-sfkmbFbA93zaBMzV3XSsKEJa_BWIqUzxw,57
|
|
161
|
+
stouputils-1.19.0.dist-info/METADATA,sha256=CsDwe4ywRAflcv8_265i20qTTmt0kWLCwYgPL2kWOo0,14007
|
|
162
|
+
stouputils-1.19.0.dist-info/RECORD,,
|
|
File without changes
|