knit-graphs 0.0.5__py3-none-any.whl → 0.0.7__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.
- knit_graphs-0.0.5.dist-info/licenses/LICENSE → LICENSE +21 -21
- README.md +75 -0
- docs/Makefile +20 -0
- docs/make.bat +35 -0
- docs/source/api/knit_graphs.artin_wale_braids.rst +58 -0
- docs/source/api/knit_graphs.rst +74 -0
- docs/source/conf.py +335 -0
- docs/source/index.rst +71 -0
- docs/source/installation.rst +67 -0
- knit_graphs/Course.py +156 -104
- knit_graphs/Knit_Graph.py +249 -186
- knit_graphs/Knit_Graph_Visualizer.py +680 -0
- knit_graphs/Loop.py +141 -155
- knit_graphs/Pull_Direction.py +68 -23
- knit_graphs/Yarn.py +424 -267
- knit_graphs/__init__.py +3 -3
- knit_graphs/_base_classes.py +173 -0
- knit_graphs/artin_wale_braids/Crossing_Direction.py +74 -15
- knit_graphs/artin_wale_braids/Loop_Braid_Graph.py +95 -62
- knit_graphs/artin_wale_braids/Wale.py +169 -93
- knit_graphs/artin_wale_braids/Wale_Braid.py +50 -30
- knit_graphs/artin_wale_braids/Wale_Braid_Word.py +99 -54
- knit_graphs/artin_wale_braids/Wale_Group.py +136 -88
- knit_graphs/{knit_graph_generators/basic_knit_graph_generators.py → basic_knit_graph_generators.py} +302 -248
- knit_graphs-0.0.7.dist-info/LICENSE +21 -0
- {knit_graphs-0.0.5.dist-info → knit_graphs-0.0.7.dist-info}/METADATA +33 -25
- knit_graphs-0.0.7.dist-info/RECORD +29 -0
- {knit_graphs-0.0.5.dist-info → knit_graphs-0.0.7.dist-info}/WHEEL +1 -1
- knit_graphs/__about__.py +0 -4
- knit_graphs/knit_graph_generators/__init__.py +0 -0
- knit_graphs/knit_graph_visualizer/Stitch_Visualizer.py +0 -427
- knit_graphs/knit_graph_visualizer/__init__.py +0 -0
- knit_graphs-0.0.5.dist-info/RECORD +0 -22
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Megan Hofmann
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Megan Hofmann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# knit_graphs
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/knit-graphs)
|
|
4
|
+
[](https://pypi.org/project/knit-graphs)
|
|
5
|
+
|
|
6
|
+
-----
|
|
7
|
+
## Description
|
|
8
|
+
The knit-graphs packaged provides a data structure for representing knitted structures formed of loops of yarn (nodes) connected by various edge structures. Loops are connected by: floats (yarn-edges) in a yarn graph structure, stitch edges (loops pulled through loops), and crossed over each other in a wale-braid structure.
|
|
9
|
+
|
|
10
|
+
Knit graphs provide a powerful tool for representing knitted structures for digital fabrication systems such as knitting machine programming languages and design tools.
|
|
11
|
+
|
|
12
|
+
Additional details about this knit-graph construction are available in the ACM publication:
|
|
13
|
+
["KnitPicking Texture: Programming and Modifying Complex Knitted Textures for Machine and Hand Knitting"](https://doi.org/10.1145/3332165.3347886)
|
|
14
|
+
|
|
15
|
+
## Table of Contents
|
|
16
|
+
- [Description](#description)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Knit Graph Generators](#knit-graph-generators)
|
|
20
|
+
- [Visualizing Knit Graphs](#visualizing-knit-graphs)
|
|
21
|
+
- [Credits](#credits)
|
|
22
|
+
- [License](#license)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```console
|
|
29
|
+
pip install knit-graphs
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Knit Graph Generators
|
|
35
|
+
The [knit-graph-generators subpackage](https://github.com/mhofmann-Khoury/knit_graph/tree/main/src/knit_graphs/knit_graph_generators) provides a library of basic knit graphs to generate such as casting on loops of a knitted structure, creating Jersey (aka Stockinette) tubes and swatches, and other basic textures.
|
|
36
|
+
For example, to generate a swatch of knit-purl ribbing use the following:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from knit_graphs.basic_knit_graph_generators import kp_rib_swatch
|
|
40
|
+
|
|
41
|
+
width = 10
|
|
42
|
+
height = 10
|
|
43
|
+
kp_rib_swatch = kp_rib_swatch(width, height)
|
|
44
|
+
```
|
|
45
|
+
Additional examples of knitgraph generator usage can be found in the [Knit_Graph test module](https://github.com/mhofmann-Khoury/knit_graph/blob/main/tests/test_Knit_Graph.py).
|
|
46
|
+
|
|
47
|
+
Knitgraphs can be created without generators. We encourage users to review the generators as simple examples on creating a knit graph programmatically.
|
|
48
|
+
|
|
49
|
+
### Visualizing Knit Graphs
|
|
50
|
+
We provide simple support for visualizing knit graphs. This is primarily used to debugging simple knit graph programs.
|
|
51
|
+
|
|
52
|
+
For example, we can visualize a swatch of seed stitch (checkered knit and purl stitches) with the following code.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from knit_graphs.basic_knit_graph_generators import seed_swatch
|
|
56
|
+
from knit_graphs.knit_graph_visualizer.Stitch_Visualizer import visualize_stitches
|
|
57
|
+
|
|
58
|
+
width = 4
|
|
59
|
+
height = 4
|
|
60
|
+
swatch = seed_swatch(width, height)
|
|
61
|
+
visualize_stitches(swatch)
|
|
62
|
+
```
|
|
63
|
+
The visualizer shows knit stitches (loops pulled from the back of the fabric to the front) as blue edges and purl stitches (loops pulled from the front to back) (aka back-knits) as red edges. Loop nodes are circles labeled with their time-ordered index and colored to match their yarn (defaults to dark green). The yarn edges (aka floats) connecting them are made of thin edges the same color as the loop nodes.
|
|
64
|
+
|
|
65
|
+
Additional examples of using the visualizer are available in the [Stitch Visualizer Tests Module](https://github.com/mhofmann-Khoury/knit_graph/blob/main/tests/test_Stitch_Visualizer.py)
|
|
66
|
+
|
|
67
|
+
## Credits
|
|
68
|
+
The design of this data scructure was completed by the authors of
|
|
69
|
+
["KnitPicking Texture: Programming and Modifying Complex Knitted Textures for Machine and Hand Knitting"](https://doi.org/10.1145/3332165.3347886).
|
|
70
|
+
|
|
71
|
+
The inclusion of the Artin-Braide wale crossing construction was inspired by ["An Artin Braid Group Representation of Knitting Machine State with Applications to Validation and Optimization of Fabrication Plans"](https://doi.org/10.1109/ICRA48506.2021.9562113) by Jenny Lin and James McCann.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
`knit-graphs` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
docs/Makefile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
docs/make.bat
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
knit\_graphs.artin\_wale\_braids package
|
|
2
|
+
========================================
|
|
3
|
+
|
|
4
|
+
.. automodule:: knit_graphs.artin_wale_braids
|
|
5
|
+
:members:
|
|
6
|
+
:undoc-members:
|
|
7
|
+
:show-inheritance:
|
|
8
|
+
|
|
9
|
+
Submodules
|
|
10
|
+
----------
|
|
11
|
+
|
|
12
|
+
knit\_graphs.artin\_wale\_braids.Crossing\_Direction module
|
|
13
|
+
-----------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
.. automodule:: knit_graphs.artin_wale_braids.Crossing_Direction
|
|
16
|
+
:members:
|
|
17
|
+
:undoc-members:
|
|
18
|
+
:show-inheritance:
|
|
19
|
+
|
|
20
|
+
knit\_graphs.artin\_wale\_braids.Loop\_Braid\_Graph module
|
|
21
|
+
----------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
.. automodule:: knit_graphs.artin_wale_braids.Loop_Braid_Graph
|
|
24
|
+
:members:
|
|
25
|
+
:undoc-members:
|
|
26
|
+
:show-inheritance:
|
|
27
|
+
|
|
28
|
+
knit\_graphs.artin\_wale\_braids.Wale module
|
|
29
|
+
--------------------------------------------
|
|
30
|
+
|
|
31
|
+
.. automodule:: knit_graphs.artin_wale_braids.Wale
|
|
32
|
+
:members:
|
|
33
|
+
:undoc-members:
|
|
34
|
+
:show-inheritance:
|
|
35
|
+
|
|
36
|
+
knit\_graphs.artin\_wale\_braids.Wale\_Braid module
|
|
37
|
+
---------------------------------------------------
|
|
38
|
+
|
|
39
|
+
.. automodule:: knit_graphs.artin_wale_braids.Wale_Braid
|
|
40
|
+
:members:
|
|
41
|
+
:undoc-members:
|
|
42
|
+
:show-inheritance:
|
|
43
|
+
|
|
44
|
+
knit\_graphs.artin\_wale\_braids.Wale\_Braid\_Word module
|
|
45
|
+
---------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
.. automodule:: knit_graphs.artin_wale_braids.Wale_Braid_Word
|
|
48
|
+
:members:
|
|
49
|
+
:undoc-members:
|
|
50
|
+
:show-inheritance:
|
|
51
|
+
|
|
52
|
+
knit\_graphs.artin\_wale\_braids.Wale\_Group module
|
|
53
|
+
---------------------------------------------------
|
|
54
|
+
|
|
55
|
+
.. automodule:: knit_graphs.artin_wale_braids.Wale_Group
|
|
56
|
+
:members:
|
|
57
|
+
:undoc-members:
|
|
58
|
+
:show-inheritance:
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
knit\_graphs package
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
.. automodule:: knit_graphs
|
|
5
|
+
:members:
|
|
6
|
+
:undoc-members:
|
|
7
|
+
:show-inheritance:
|
|
8
|
+
|
|
9
|
+
Subpackages
|
|
10
|
+
-----------
|
|
11
|
+
|
|
12
|
+
.. toctree::
|
|
13
|
+
:maxdepth: 4
|
|
14
|
+
|
|
15
|
+
knit_graphs.artin_wale_braids
|
|
16
|
+
|
|
17
|
+
Submodules
|
|
18
|
+
----------
|
|
19
|
+
|
|
20
|
+
knit\_graphs.Course module
|
|
21
|
+
--------------------------
|
|
22
|
+
|
|
23
|
+
.. automodule:: knit_graphs.Course
|
|
24
|
+
:members:
|
|
25
|
+
:undoc-members:
|
|
26
|
+
:show-inheritance:
|
|
27
|
+
|
|
28
|
+
knit\_graphs.Knit\_Graph module
|
|
29
|
+
-------------------------------
|
|
30
|
+
|
|
31
|
+
.. automodule:: knit_graphs.Knit_Graph
|
|
32
|
+
:members:
|
|
33
|
+
:undoc-members:
|
|
34
|
+
:show-inheritance:
|
|
35
|
+
|
|
36
|
+
knit\_graphs.Knit\_Graph\_Visualizer module
|
|
37
|
+
-------------------------------------------
|
|
38
|
+
|
|
39
|
+
.. automodule:: knit_graphs.Knit_Graph_Visualizer
|
|
40
|
+
:members:
|
|
41
|
+
:undoc-members:
|
|
42
|
+
:show-inheritance:
|
|
43
|
+
|
|
44
|
+
knit\_graphs.Loop module
|
|
45
|
+
------------------------
|
|
46
|
+
|
|
47
|
+
.. automodule:: knit_graphs.Loop
|
|
48
|
+
:members:
|
|
49
|
+
:undoc-members:
|
|
50
|
+
:show-inheritance:
|
|
51
|
+
|
|
52
|
+
knit\_graphs.Pull\_Direction module
|
|
53
|
+
-----------------------------------
|
|
54
|
+
|
|
55
|
+
.. automodule:: knit_graphs.Pull_Direction
|
|
56
|
+
:members:
|
|
57
|
+
:undoc-members:
|
|
58
|
+
:show-inheritance:
|
|
59
|
+
|
|
60
|
+
knit\_graphs.Yarn module
|
|
61
|
+
------------------------
|
|
62
|
+
|
|
63
|
+
.. automodule:: knit_graphs.Yarn
|
|
64
|
+
:members:
|
|
65
|
+
:undoc-members:
|
|
66
|
+
:show-inheritance:
|
|
67
|
+
|
|
68
|
+
knit\_graphs.basic\_knit\_graph\_generators module
|
|
69
|
+
--------------------------------------------------
|
|
70
|
+
|
|
71
|
+
.. automodule:: knit_graphs.basic_knit_graph_generators
|
|
72
|
+
:members:
|
|
73
|
+
:undoc-members:
|
|
74
|
+
:show-inheritance:
|
docs/source/conf.py
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Configuration file for the Sphinx documentation builder.
|
|
3
|
+
=============================================================================
|
|
4
|
+
SPHINX DOCUMENTATION CONFIGURATION
|
|
5
|
+
=============================================================================
|
|
6
|
+
This file configures how Sphinx generates documentation from your Python code.
|
|
7
|
+
For the full list of built-in configuration values, see:
|
|
8
|
+
https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
from datetime import datetime
|
|
14
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
15
|
+
|
|
16
|
+
# =============================================================================
|
|
17
|
+
# PATH SETUP
|
|
18
|
+
# =============================================================================
|
|
19
|
+
# Add the project root and source directory to Python path so Sphinx can import your modules
|
|
20
|
+
|
|
21
|
+
# Path to your source code (adjust if not using src/ layout)
|
|
22
|
+
sys.path.insert(0, os.path.abspath('..')) # Project root
|
|
23
|
+
sys.path.insert(0, os.path.abspath('../src')) # Source directory
|
|
24
|
+
sys.path.insert(0, os.path.abspath('.')) # Docs directory
|
|
25
|
+
|
|
26
|
+
# =============================================================================
|
|
27
|
+
# PROJECT INFORMATION
|
|
28
|
+
# =============================================================================
|
|
29
|
+
|
|
30
|
+
project = 'knit-graphs'
|
|
31
|
+
copyright = f'{datetime.now().year}, Megan Hofmann'
|
|
32
|
+
author = 'Megan Hofmann'
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
# Get version from installed package metadata
|
|
36
|
+
# This reads from pyproject.toml when the package is installed
|
|
37
|
+
version = version("knit-graphs")
|
|
38
|
+
except PackageNotFoundError:
|
|
39
|
+
# Package is not installed (e.g., during development)
|
|
40
|
+
# This happens when running from source without installation
|
|
41
|
+
version = "0.0.0+dev"
|
|
42
|
+
|
|
43
|
+
release = version
|
|
44
|
+
|
|
45
|
+
# =============================================================================
|
|
46
|
+
# GENERAL CONFIGURATION
|
|
47
|
+
# =============================================================================
|
|
48
|
+
|
|
49
|
+
# Extensions to enable (these add functionality to Sphinx)
|
|
50
|
+
extensions = [
|
|
51
|
+
# Core Sphinx extensions
|
|
52
|
+
'sphinx.ext.autodoc', # Generate docs from docstrings
|
|
53
|
+
'sphinx.ext.autosummary', # Generate summary tables automatically
|
|
54
|
+
'sphinx.ext.viewcode', # Add [source] links to documentation
|
|
55
|
+
'sphinx.ext.napoleon', # Support Google/NumPy docstring styles
|
|
56
|
+
'sphinx.ext.intersphinx', # Link to other project docs (e.g., Python docs)
|
|
57
|
+
'sphinx.ext.githubpages', # Publish to GitHub Pages (.nojekyll file)
|
|
58
|
+
'sphinx.ext.todo', # Support TODO items in docs
|
|
59
|
+
'sphinx.ext.coverage', # Check documentation coverage
|
|
60
|
+
'sphinx.ext.doctest', # Test code snippets in documentation
|
|
61
|
+
|
|
62
|
+
# Third-party extensions (these need to be installed)
|
|
63
|
+
'sphinx_autodoc_typehints', # Better type hint rendering
|
|
64
|
+
'myst_parser', # Support for Markdown files (optional)
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
# =============================================================================
|
|
68
|
+
# SOURCE FILE CONFIGURATION
|
|
69
|
+
# =============================================================================
|
|
70
|
+
|
|
71
|
+
# File extensions that Sphinx will process
|
|
72
|
+
source_suffix = {
|
|
73
|
+
'.rst': None, # RestructuredText (default)
|
|
74
|
+
'.md': 'myst_parser', # Markdown (requires myst_parser extension)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# The master toctree document (main page)
|
|
78
|
+
master_doc = 'index'
|
|
79
|
+
|
|
80
|
+
# Files and directories to exclude from processing
|
|
81
|
+
exclude_patterns = [
|
|
82
|
+
'_build', # Build output directory
|
|
83
|
+
'Thumbs.db', # Windows thumbnail cache
|
|
84
|
+
'.DS_Store', # macOS metadata
|
|
85
|
+
'**.ipynb_checkpoints', # Jupyter notebook checkpoints
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
# =============================================================================
|
|
89
|
+
# HTML OUTPUT CONFIGURATION
|
|
90
|
+
# =============================================================================
|
|
91
|
+
|
|
92
|
+
# The theme to use for HTML pages
|
|
93
|
+
html_theme = 'sphinx_rtd_theme' # Read the Docs theme (clean, professional)
|
|
94
|
+
|
|
95
|
+
# Directories containing static files (CSS, JS, images)
|
|
96
|
+
html_static_path = ['_static']
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# Theme-specific options
|
|
100
|
+
html_theme_options = {
|
|
101
|
+
'logo_only': False, # Show project name with logo
|
|
102
|
+
'display_version': True, # Show version in sidebar
|
|
103
|
+
'prev_next_buttons_location': 'bottom', # Navigation button placement
|
|
104
|
+
'style_external_links': True, # Style external links differently
|
|
105
|
+
'vcs_pageview_mode': '', # Version control integration
|
|
106
|
+
'style_nav_header_background': '#2980B9', # Header background color
|
|
107
|
+
|
|
108
|
+
# Table of contents options
|
|
109
|
+
'collapse_navigation': True, # Collapse subsections in nav
|
|
110
|
+
'sticky_navigation': True, # Keep navigation visible on scroll
|
|
111
|
+
'navigation_depth': 4, # Maximum navigation depth
|
|
112
|
+
'includehidden': True, # Include hidden toctrees
|
|
113
|
+
'titles_only': False, # Show subsection titles in nav
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Additional HTML options
|
|
117
|
+
html_title = f'{project} Documentation' # Browser window title
|
|
118
|
+
html_short_title = project # Short title for navigation
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# html_logo = '_static/logo.png'
|
|
122
|
+
# html_favicon = '_static/favicon.ico'
|
|
123
|
+
|
|
124
|
+
# Show "Edit on GitHub" links (requires proper URL)
|
|
125
|
+
# html_context = {
|
|
126
|
+
# 'github_user': 'your-username',
|
|
127
|
+
# 'github_repo': 'your-repo-name',
|
|
128
|
+
# 'github_version': 'main',
|
|
129
|
+
# 'doc_path': 'docs',
|
|
130
|
+
# }
|
|
131
|
+
|
|
132
|
+
# =============================================================================
|
|
133
|
+
# AUTODOC CONFIGURATION
|
|
134
|
+
# =============================================================================
|
|
135
|
+
# Controls how automatic documentation is generated from Python code
|
|
136
|
+
|
|
137
|
+
# Default options for all autodoc directives
|
|
138
|
+
autodoc_default_options = {
|
|
139
|
+
'members': True, # Include all members
|
|
140
|
+
'member-order': 'bysource', # Order members as they appear in source
|
|
141
|
+
'special-members': '__init__', # Include __init__ methods
|
|
142
|
+
'undoc-members': True, # Include members without docstrings
|
|
143
|
+
'exclude-members': '__weakref__', # Exclude certain members
|
|
144
|
+
'show-inheritance': True, # Show class inheritance
|
|
145
|
+
'inherited-members': True, # Include inherited methods
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# How to display class signatures
|
|
149
|
+
autodoc_class_signature = "mixed" # Show __init__ parameters with class
|
|
150
|
+
|
|
151
|
+
# Order of members in documentation
|
|
152
|
+
autodoc_member_order = 'bysource' # bysource, alphabetical, or groupwise
|
|
153
|
+
|
|
154
|
+
# Mock imports for modules that might not be available during doc building
|
|
155
|
+
# Add any modules that cause import errors during doc building
|
|
156
|
+
autodoc_mock_imports = [
|
|
157
|
+
# 'numpy',
|
|
158
|
+
# 'pandas',
|
|
159
|
+
# 'some_optional_dependency',
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
# =============================================================================
|
|
163
|
+
# AUTOSUMMARY CONFIGURATION
|
|
164
|
+
# =============================================================================
|
|
165
|
+
# Controls automatic generation of summary tables
|
|
166
|
+
|
|
167
|
+
autosummary_generate = True # Generate stub pages for autosummary
|
|
168
|
+
autosummary_imported_members = True # Include imported members
|
|
169
|
+
|
|
170
|
+
# =============================================================================
|
|
171
|
+
# NAPOLEON CONFIGURATION (DOCSTRING STYLES)
|
|
172
|
+
# =============================================================================
|
|
173
|
+
# Configures support for Google and NumPy style docstrings
|
|
174
|
+
|
|
175
|
+
napoleon_google_docstring = True # Parse Google-style docstrings
|
|
176
|
+
napoleon_numpy_docstring = True # Parse NumPy-style docstrings
|
|
177
|
+
napoleon_include_init_with_doc = True # Include __init__ docstring with class
|
|
178
|
+
napoleon_include_private_with_doc = False # Don't document private members
|
|
179
|
+
napoleon_include_special_with_doc = True # Document special methods (__str__, etc.)
|
|
180
|
+
napoleon_use_admonition_for_examples = False # Style for Examples sections
|
|
181
|
+
napoleon_use_admonition_for_notes = False # Style for Notes sections
|
|
182
|
+
napoleon_use_admonition_for_references = False # Style for References sections
|
|
183
|
+
napoleon_use_ivar = False # Use :ivar: for instance variables
|
|
184
|
+
napoleon_use_param = True # Use :param: for parameters
|
|
185
|
+
napoleon_use_rtype = True # Use :rtype: for return types
|
|
186
|
+
napoleon_preprocess_types = False # Preprocess type annotations
|
|
187
|
+
napoleon_type_aliases = None # Custom type aliases
|
|
188
|
+
napoleon_attr_annotations = True # Include attribute annotations
|
|
189
|
+
|
|
190
|
+
# =============================================================================
|
|
191
|
+
# INTERSPHINX CONFIGURATION
|
|
192
|
+
# =============================================================================
|
|
193
|
+
# Links to external documentation
|
|
194
|
+
|
|
195
|
+
intersphinx_mapping = {
|
|
196
|
+
'python': ('https://docs.python.org/3', None),
|
|
197
|
+
'numpy': ('https://numpy.org/doc/stable/', None),
|
|
198
|
+
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
|
|
199
|
+
'matplotlib': ('https://matplotlib.org/stable/', None),
|
|
200
|
+
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
|
|
201
|
+
'sklearn': ('https://scikit-learn.org/stable/', None),
|
|
202
|
+
'typing': ('https://typing.readthedocs.io/en/latest/', None),
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
# =============================================================================
|
|
206
|
+
# TYPE HINTS CONFIGURATION
|
|
207
|
+
# =============================================================================
|
|
208
|
+
# Controls how type hints are displayed in documentation
|
|
209
|
+
|
|
210
|
+
typehints_fully_qualified = False # Use short names for types
|
|
211
|
+
always_document_param_types = True # Always show parameter types
|
|
212
|
+
typehints_document_rtype = True # Document return types
|
|
213
|
+
typehints_use_rtype = True # Use :rtype: directive for return types
|
|
214
|
+
|
|
215
|
+
# =============================================================================
|
|
216
|
+
# TODO EXTENSION CONFIGURATION
|
|
217
|
+
# =============================================================================
|
|
218
|
+
|
|
219
|
+
todo_include_todos = True # Include TODO items in documentation
|
|
220
|
+
todo_emit_warnings = True # Warn about TODO items during build
|
|
221
|
+
|
|
222
|
+
# =============================================================================
|
|
223
|
+
# COVERAGE EXTENSION CONFIGURATION
|
|
224
|
+
# =============================================================================
|
|
225
|
+
# Checks what's documented vs what's not
|
|
226
|
+
|
|
227
|
+
coverage_ignore_modules = [
|
|
228
|
+
# Add modules to ignore in coverage reports
|
|
229
|
+
]
|
|
230
|
+
coverage_ignore_functions = [
|
|
231
|
+
# Add functions to ignore in coverage reports
|
|
232
|
+
]
|
|
233
|
+
coverage_ignore_classes = [
|
|
234
|
+
# Add classes to ignore in coverage reports
|
|
235
|
+
]
|
|
236
|
+
|
|
237
|
+
# =============================================================================
|
|
238
|
+
# ADDITIONAL CUSTOMIZATION
|
|
239
|
+
# =============================================================================
|
|
240
|
+
|
|
241
|
+
# Control how module names are displayed
|
|
242
|
+
add_module_names = False # Don't prepend module names to functions
|
|
243
|
+
|
|
244
|
+
# Show author information in output
|
|
245
|
+
show_authors = False # Don't show author info by default
|
|
246
|
+
|
|
247
|
+
# Syntax highlighting style
|
|
248
|
+
pygments_style = 'sphinx' # Code highlighting theme
|
|
249
|
+
|
|
250
|
+
# Language for content that doesn't specify a language
|
|
251
|
+
language = 'en'
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
# =============================================================================
|
|
255
|
+
# CUSTOM FUNCTIONS AND SETUP
|
|
256
|
+
# =============================================================================
|
|
257
|
+
|
|
258
|
+
def autodoc_skip_member(app, what, name, obj, skip, options):
|
|
259
|
+
"""
|
|
260
|
+
Custom function to control which members are included in documentation.
|
|
261
|
+
|
|
262
|
+
Args:
|
|
263
|
+
app: The Sphinx application instance
|
|
264
|
+
what: The type of the object (module, class, function, etc.)
|
|
265
|
+
name: The fully qualified name of the object
|
|
266
|
+
obj: The object itself
|
|
267
|
+
skip: Boolean indicating if this member should be skipped
|
|
268
|
+
options: The options given to the directive
|
|
269
|
+
|
|
270
|
+
Returns:
|
|
271
|
+
Boolean indicating whether to skip this member
|
|
272
|
+
"""
|
|
273
|
+
# Add custom logic to skip certain members
|
|
274
|
+
# Example: Skip private methods that start with underscore
|
|
275
|
+
# if name.startswith('_') and not name.startswith('__'):
|
|
276
|
+
# return True
|
|
277
|
+
|
|
278
|
+
return skip
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def setup(app):
|
|
282
|
+
"""
|
|
283
|
+
Custom Sphinx setup function.
|
|
284
|
+
This function is called when Sphinx initializes and allows you to
|
|
285
|
+
add custom functionality, connect to events, etc.
|
|
286
|
+
|
|
287
|
+
Args:
|
|
288
|
+
app: The Sphinx application instance
|
|
289
|
+
"""
|
|
290
|
+
# Connect custom functions to Sphinx events
|
|
291
|
+
app.connect('autodoc-skip-member', autodoc_skip_member)
|
|
292
|
+
|
|
293
|
+
# Return extension metadata
|
|
294
|
+
return {
|
|
295
|
+
'version': version,
|
|
296
|
+
'parallel_read_safe': True,
|
|
297
|
+
'parallel_write_safe': True,
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
# =============================================================================
|
|
301
|
+
# CHECKLIST FOR SPHINX SETUP
|
|
302
|
+
# =============================================================================
|
|
303
|
+
# When using this configuration:
|
|
304
|
+
#
|
|
305
|
+
# 1. BASIC SETUP:
|
|
306
|
+
# - [ ] Update project, author, and copyright information
|
|
307
|
+
# - [ ] Set correct version/release values
|
|
308
|
+
# - [ ] Verify source code paths are correct
|
|
309
|
+
# - [ ] Create docs/_static/ directory for custom files
|
|
310
|
+
#
|
|
311
|
+
# 2. CONTENT CREATION:
|
|
312
|
+
# - [ ] Create docs/index.rst (main page)
|
|
313
|
+
# - [ ] Create docs/installation.rst (installation guide)
|
|
314
|
+
# - [ ] Create docs/usage.rst (usage examples)
|
|
315
|
+
# - [ ] Create docs/api.rst (API reference)
|
|
316
|
+
#
|
|
317
|
+
# 3. CUSTOMIZATION:
|
|
318
|
+
# - [ ] Choose and configure theme options
|
|
319
|
+
# - [ ] Add logo and favicon to _static/
|
|
320
|
+
# - [ ] Create custom CSS/JS if needed
|
|
321
|
+
# - [ ] Configure intersphinx for your dependencies
|
|
322
|
+
#
|
|
323
|
+
# 4. TESTING:
|
|
324
|
+
# - [ ] Run: poetry run sphinx-build docs/ docs/_build/html/
|
|
325
|
+
# - [ ] Check output in docs/_build/html/index.html
|
|
326
|
+
# - [ ] Fix any warnings or errors
|
|
327
|
+
#
|
|
328
|
+
# 5. GITHUB PAGES:
|
|
329
|
+
# - [ ] Ensure githubpages extension is enabled
|
|
330
|
+
# - [ ] Configure GitHub repository Pages settings
|
|
331
|
+
# - [ ] Test deployment with GitHub Actions workflow
|
|
332
|
+
#
|
|
333
|
+
# COMMON COMMANDS:
|
|
334
|
+
# poetry run sphinx-apidoc -o docs/source/api src/your_project_name/ --force --module-first # Generate API docs
|
|
335
|
+
# poetry run sphinx-build docs/source/ docs/build/html/ # Build documentation
|