clear-skies-doc-builder 2.0.5__py3-none-any.whl → 2.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.
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.4
2
+ Name: clear-skies-doc-builder
3
+ Version: 2.0.7
4
+ Summary: The docbuilder for all 'official' clearskies plugins (as well as the main clearskies docs)
5
+ Project-URL: repository, https://github.com/clearskies-py/docs
6
+ Project-URL: issues, https://github.com/clearskies-py/docs/issues
7
+ Project-URL: changelog, https://github.com/clearskies-py/docs/blob/main/CHANGELOG.md
8
+ Author-email: Conor Mancone <cmancone@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: <4.0,>=3.11
16
+ Requires-Dist: clear-skies<3.0.0,>=2.0.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: types-requests>=2.32.4; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # docs
22
+
23
+ The documentation builder for clearskies and related plugins
24
+
25
+ ## Overview
26
+
27
+ Each "official" clearskies module (including the core clearskies library itself) has the documentation primarily written in the codebase as docblocks. The documentation site is then built by extracting these docblocks and stitching them together. To be clear, this isn't about the low-level "API" documentation that describes every single class/method in the framework. Rather, this is about the primary documentation site itself (clearskies.info) which is focused on high-level use cases and examples of the primary configuration options. As a result, it's not a simple matter of just iterating over the classes/methods and building documentation. To build a coherent documentation site, each plugin has a configuration file that basically outlines the final "structure" or organization of the resulting documentation, as well as the name of a builder class that will combine that configuration information with the codebase itself to create the actual docs.
28
+
29
+ The docs themselves (in the source code) are all written with markdown. This documentation builder then takes that markdwon and adds the necessary headers/etc so to make them valid files for [Jekyll](https://jekyllrb.com/), the builder for the current documentation site. The site itself is hosted in S3, so building an actual documentation site means:
30
+
31
+ 1. Properly documenting everything inside of the source code via markdown.
32
+ 2. Creating a config file (`docs/python/config.json`) to map source code docs to Jekyll files.
33
+ 3. Creating a skeleton of a Jekyll site in the `doc/jekyll` folder of the plugin.
34
+ 4. Installing this doc builder via `poetry add clear-skies-doc-builder`.
35
+ 5. Run the doc builder.
36
+ 6. Build with Jekyll.
37
+ 7. Push to the appropriate subfolder via S3.
38
+ 8. (Only once) Update the main clearskies doc site to know about the new subfolder for this plugin.
39
+
40
+ Of course, we want the Jekyll sites to be consistent with eachother in terms of style/look. In the long run we'll probably have this doc builder also bootstrap the Jekyll site, but for now you just have to manually setup the Jekyll build using the main clearskies repo as a template.
41
+
42
+ ## Configuration File Structure
43
+
44
+ The `config.json` file defines the documentation structure using a tree of entries. Each entry specifies a documentation section with its source class and builder.
45
+
46
+ ### Basic Structure
47
+
48
+ ```json
49
+ {
50
+ "tree": [
51
+ {
52
+ "title": "Section Title",
53
+ "source": "package.module.ClassName",
54
+ "builder": "clearskies_doc_builder.builders.Module",
55
+ "classes": ["package.module.Class1", "package.module.Class2"]
56
+ }
57
+ ]
58
+ }
59
+ ```
60
+
61
+ ### Nested Hierarchy (Parent/Grand-Parent)
62
+
63
+ The doc builder supports up to 3 levels of navigation hierarchy using `parent` and `grand_parent` fields. This is useful for organizing documentation of submodules under a common heading.
64
+
65
+ #### Two-Level Hierarchy (Parent) - Module with Classes
66
+
67
+ Use this when you want to document a submodule's classes under a parent section:
68
+
69
+ ```json
70
+ {
71
+ "tree": [
72
+ {
73
+ "title": "Cursors",
74
+ "source": "clearskies.cursors.Cursor",
75
+ "builder": "clearskies_doc_builder.builders.Module",
76
+ "classes": [
77
+ "clearskies.cursors.MemoryCursor",
78
+ "clearskies.cursors.FileCursor"
79
+ ]
80
+ },
81
+ {
82
+ "title": "From Environment",
83
+ "source": "clearskies.cursors.from_environment.FromEnvironmentBase",
84
+ "builder": "clearskies_doc_builder.builders.Module",
85
+ "parent": "Cursors",
86
+ "classes": [
87
+ "clearskies.cursors.from_environment.EnvCursor",
88
+ "clearskies.cursors.from_environment.SecretsCursor"
89
+ ]
90
+ }
91
+ ]
92
+ }
93
+ ```
94
+
95
+ This creates:
96
+ - `docs/cursors/index.md` - Parent section with overview
97
+ - `docs/cursors/memory-cursor.md` - Class documentation
98
+ - `docs/cursors/file-cursor.md` - Class documentation
99
+ - `docs/cursors/from-environment/index.md` - Submodule section with `parent: Cursors`
100
+ - `docs/cursors/from-environment/env-cursor.md` - Class with `parent: From Environment`
101
+ - `docs/cursors/from-environment/secrets-cursor.md` - Class with `parent: From Environment`
102
+
103
+ #### Three-Level Hierarchy (Grand-Parent)
104
+
105
+ For deeper nesting, use `grand_parent` to create a third level:
106
+
107
+ ```json
108
+ {
109
+ "tree": [
110
+ {
111
+ "title": "Cursors",
112
+ "source": "clearskies.cursors.Cursor",
113
+ "builder": "clearskies_doc_builder.builders.Module",
114
+ "classes": ["clearskies.cursors.MemoryCursor"]
115
+ },
116
+ {
117
+ "title": "From Environment",
118
+ "source": "clearskies.cursors.from_environment.FromEnvironmentBase",
119
+ "builder": "clearskies_doc_builder.builders.SingleClass",
120
+ "parent": "Cursors"
121
+ },
122
+ {
123
+ "title": "AWS Secrets",
124
+ "source": "clearskies.cursors.from_environment.aws.AWSSecretsBase",
125
+ "builder": "clearskies_doc_builder.builders.Module",
126
+ "parent": "From Environment",
127
+ "grand_parent": "Cursors",
128
+ "classes": [
129
+ "clearskies.cursors.from_environment.aws.SecretsManagerCursor",
130
+ "clearskies.cursors.from_environment.aws.ParameterStoreCursor"
131
+ ]
132
+ }
133
+ ]
134
+ }
135
+ ```
136
+
137
+ This creates:
138
+ - `docs/cursors/index.md` - Grand-parent section
139
+ - `docs/cursors/from-environment/index.md` - Parent section with `parent: Cursors`
140
+ - `docs/cursors/from-environment/aws-secrets/index.md` - Child section with `parent: From Environment` and `grand_parent: Cursors`
141
+ - `docs/cursors/from-environment/aws-secrets/secrets-manager-cursor.md` - Class documentation
142
+
143
+ The `grand_parent` field enables the Jekyll "just-the-docs" theme's three-level navigation, allowing you to document submodule classes under their logical grouping.
144
+
145
+ #### Using SingleClass for Individual Classes
146
+
147
+ You can also use `SingleClass` builder for documenting individual classes within a hierarchy:
148
+
149
+ ```json
150
+ {
151
+ "tree": [
152
+ {
153
+ "title": "Cursors",
154
+ "source": "clearskies.cursors.Cursor",
155
+ "builder": "clearskies_doc_builder.builders.SingleClass"
156
+ },
157
+ {
158
+ "title": "Environment Cursor",
159
+ "source": "clearskies.cursors.from_environment.EnvironmentCursor",
160
+ "builder": "clearskies_doc_builder.builders.SingleClass",
161
+ "parent": "Cursors"
162
+ }
163
+ ]
164
+ }
165
+ ```
@@ -1,15 +1,15 @@
1
1
  clearskies_doc_builder/__init__.py,sha256=AFQzZ9HwIxPyLpsUhkSDRh_6hm8-5H4RpAelTShCDTc,1300
2
- clearskies_doc_builder/build_callable.py,sha256=9_HrytRA5MeGpuUKRFgmlK5Mb1WKt6TfWlCOi1aS-Pc,983
2
+ clearskies_doc_builder/build_callable.py,sha256=sCjXSnqFU-27zr2-i5D5I3M0ebDWO4OEvikvSNQg6oA,1608
3
3
  clearskies_doc_builder/prepare_doc_space.py,sha256=BXIH-CQJ1ZY6sf2bj1Fjhrglihls6AnqMNdjirDqSFM,1019
4
4
  clearskies_doc_builder/backends/__init__.py,sha256=q5jpy8xfZ4SbGQ1T30q4mp4h346HaMivvmNqtgTMQxw,303
5
- clearskies_doc_builder/backends/attribute_backend.py,sha256=0vlnREe3TcYjrmBFvAlTFeWzQ-LzT__wVJG7inWQLzM,3581
6
- clearskies_doc_builder/backends/class_backend.py,sha256=6jOKzUDLYIQofCxno3Y9L_FiKT9x2MsPOe3c1HJ2k2M,4031
7
- clearskies_doc_builder/backends/module_backend.py,sha256=hJMeJtgInaZfXnFpxtCuRA05jBZTpMhVrR8Se3uul9Y,5718
5
+ clearskies_doc_builder/backends/attribute_backend.py,sha256=2nivmJpedPsoQibf9NlIT-Wfvg0PbfHKoT06xKkt0O0,3634
6
+ clearskies_doc_builder/backends/class_backend.py,sha256=JIKRYAVFxYEOHV7tG9RBrfuo1SN8Uw4KKaMz5YzlMHo,4112
7
+ clearskies_doc_builder/backends/module_backend.py,sha256=hHJXt00TJIF3-69p_kjdAZuWOyGhpCvD3TgOKMOp4og,5971
8
8
  clearskies_doc_builder/backends/python.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  clearskies_doc_builder/builders/__init__.py,sha256=ndAK4-imR9vhl7CS425ASYi46FN5-eR9Dr6bKxCn5lA,292
10
- clearskies_doc_builder/builders/builder.py,sha256=3aQ_UTKJFDDUCNHKhwn1sr74CKR3YCe7xuWRX528eAw,6133
11
- clearskies_doc_builder/builders/module.py,sha256=occ49CTmX9imWK1zNHf0JAQLB46lc2mm2vnZieP-rhg,3287
12
- clearskies_doc_builder/builders/single_class.py,sha256=3JZBVtt9GToPFoSIlggWbalRFbfayLpLVb9-2-1ymdY,3454
10
+ clearskies_doc_builder/builders/builder.py,sha256=2QZDscwOZ4vfx4NzFU4AyKgAPuKVU0jsYBcT42CZgzY,7957
11
+ clearskies_doc_builder/builders/module.py,sha256=WlLSMPN3AoCaMg66DxvRXiO3x4zVFhoYGXjHM6U0M6c,4912
12
+ clearskies_doc_builder/builders/single_class.py,sha256=-3b9VC_bxB9r5EHcdUCA1VFWxY0r_N72td0ZHLydy3Y,4846
13
13
  clearskies_doc_builder/builders/single_class_to_section.py,sha256=uEyawxW4cIdavBVnK2TBiIqywUgj3IxmUcS16E81cgI,1754
14
14
  clearskies_doc_builder/columns/__init__.py,sha256=--cof8kFPwlZncM3MBQYkvfq8TejEeI0B99vTlEVCkU,566
15
15
  clearskies_doc_builder/columns/any.py,sha256=5kjwEz4-t7MH9sFyycWxEcDdDmKZsb3wfX1Nmvc6QI4,998
@@ -32,7 +32,7 @@ clearskies_doc_builder/models/method_reference.py,sha256=U4YOpRLotyEp6G0Y5OHORdo
32
32
  clearskies_doc_builder/models/module.py,sha256=5JUF2LUKTpVsYlviT7T_qgLdMApGtS4qIUloCEzJ-uo,573
33
33
  clearskies_doc_builder/models/module_reference.py,sha256=-zHnrkP6JR7j2XFuW94uGlPENI3ZshxgBu4yY9ayzSg,177
34
34
  clearskies_doc_builder/models/property.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- clear_skies_doc_builder-2.0.5.dist-info/METADATA,sha256=tePfhHwlEy6SMHEOOb4dfRQFk-l4ZfUQT-ww_X89meQ,3075
36
- clear_skies_doc_builder-2.0.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
37
- clear_skies_doc_builder-2.0.5.dist-info/licenses/LICENSE,sha256=pgH32-xrgpIDf6WIBUA1X19o-sIHIXgToCxo-tBWDdw,1071
38
- clear_skies_doc_builder-2.0.5.dist-info/RECORD,,
35
+ clear_skies_doc_builder-2.0.7.dist-info/METADATA,sha256=vOVE5Aqo5BiuVRm3QdwiE5FHfelXSRvRS_2OfKkwo_A,7036
36
+ clear_skies_doc_builder-2.0.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
37
+ clear_skies_doc_builder-2.0.7.dist-info/licenses/LICENSE,sha256=pgH32-xrgpIDf6WIBUA1X19o-sIHIXgToCxo-tBWDdw,1071
38
+ clear_skies_doc_builder-2.0.7.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -5,6 +5,7 @@ import clearskies
5
5
  import clearskies.column
6
6
  import clearskies.model
7
7
  import clearskies.query
8
+ from clearskies.query.result import RecordsQueryResult
8
9
 
9
10
  from clearskies_doc_builder.backends.module_backend import ModuleBackend
10
11
 
@@ -18,7 +19,7 @@ class AttributeBackend(ModuleBackend):
18
19
 
19
20
  def records(
20
21
  self, query: clearskies.query.Query, next_page_data: dict[str, str | int] | None = None
21
- ) -> list[dict[str, Any]]:
22
+ ) -> RecordsQueryResult:
22
23
  """
23
24
  Return a list of records that match the given query configuration.
24
25
 
@@ -7,6 +7,7 @@ import clearskies
7
7
  import clearskies.column
8
8
  import clearskies.model
9
9
  import clearskies.query
10
+ from clearskies.query.result import RecordsQueryResult
10
11
 
11
12
  from clearskies_doc_builder.backends.module_backend import ModuleBackend
12
13
 
@@ -19,7 +20,7 @@ class ClassBackend(ModuleBackend):
19
20
 
20
21
  def records(
21
22
  self, query: clearskies.query.Query, next_page_data: dict[str, str | int] | None = None
22
- ) -> list[dict[str, Any]]:
23
+ ) -> RecordsQueryResult:
23
24
  """
24
25
  Return a list of records that match the given query configuration.
25
26
 
@@ -53,7 +54,7 @@ class ClassBackend(ModuleBackend):
53
54
  raise ValueError(
54
55
  f"I was asked to import the class named '{import_path}' but this doesn't actually reference a class"
55
56
  )
56
- return [self.unpack(Class, module)]
57
+ return RecordsQueryResult(records=[self.unpack(Class, module)])
57
58
 
58
59
  if "module" not in query.conditions_by_column:
59
60
  raise ValueError(
@@ -9,6 +9,7 @@ import clearskies.model
9
9
  import clearskies.query
10
10
  from clearskies.autodoc.schema import Integer as AutoDocInteger
11
11
  from clearskies.autodoc.schema import Schema as AutoDocSchema
12
+ from clearskies.query.result import CountQueryResult, RecordQueryResult, RecordsQueryResult, SuccessQueryResult
12
13
 
13
14
 
14
15
  class ModuleBackend(clearskies.backends.Backend):
@@ -19,25 +20,25 @@ class ModuleBackend(clearskies.backends.Backend):
19
20
  "module": lambda module, value: id(module) == id(value),
20
21
  }
21
22
 
22
- def update(self, id: int | str, data: dict[str, Any], model: clearskies.model.Model) -> dict[str, Any]:
23
+ def update(self, id: int | str, data: dict[str, Any], model: clearskies.model.Model) -> RecordQueryResult:
23
24
  """Update the record with the given id with the information from the data dictionary."""
24
25
  raise Exception(f"The {self.__class__.__name__} only supports read operations: update is not allowed")
25
26
 
26
- def create(self, data: dict[str, Any], model: clearskies.model.Model) -> dict[str, Any]:
27
+ def create(self, data: dict[str, Any], model: clearskies.model.Model) -> RecordQueryResult:
27
28
  """Create a record with the information from the data dictionary."""
28
29
  raise Exception(f"The {self.__class__.__name__} only supports read operations: create is not allowed")
29
30
 
30
- def delete(self, id: int | str, model: clearskies.model.Model) -> bool:
31
+ def delete(self, id: int | str, model: clearskies.model.Model) -> SuccessQueryResult:
31
32
  """Delete the record with the given id."""
32
33
  raise Exception(f"The {self.__class__.__name__} only supports read operations: delete is not allowed")
33
34
 
34
- def count(self, query: clearskies.query.Query) -> int:
35
+ def count(self, query: clearskies.query.Query) -> CountQueryResult:
35
36
  """Return the number of records which match the given query configuration."""
36
- return len(self.records(query))
37
+ return CountQueryResult(count=len(self.records(query).records))
37
38
 
38
39
  def records(
39
40
  self, query: clearskies.query.Query, next_page_data: dict[str, str | int] | None = None
40
- ) -> list[dict[str, Any]]:
41
+ ) -> RecordsQueryResult:
41
42
  """
42
43
  Return a list of records that match the given query configuration.
43
44
 
@@ -58,7 +59,7 @@ class ModuleBackend(clearskies.backends.Backend):
58
59
  if module_name_condition:
59
60
  module_name = module_name_condition[0].values[0]
60
61
  module = importlib.import_module(module_name)
61
- return [self.unpack(module)]
62
+ return RecordsQueryResult(records=[self.unpack(module)])
62
63
 
63
64
  matching_modules = []
64
65
  module_names = set(sys.modules) & set(globals())
@@ -92,8 +93,8 @@ class ModuleBackend(clearskies.backends.Backend):
92
93
  "module": module,
93
94
  }
94
95
 
95
- def paginate(self, records, query):
96
- return records
96
+ def paginate(self, records, query) -> RecordsQueryResult:
97
+ return RecordsQueryResult(records=records)
97
98
 
98
99
  def validate_pagination_data(self, data: dict[str, Any], case_mapping: Callable) -> str:
99
100
  extra_keys = set(data.keys()) - set(self.allowed_pagination_keys())
@@ -6,19 +6,34 @@ from clearskies_doc_builder.prepare_doc_space import prepare_doc_space
6
6
 
7
7
  def build_callable(modules: models.Module, classes: models.Class, config: dict[str, Any], project_root: str):
8
8
  doc_root = prepare_doc_space(project_root)
9
- nav_order_parent_count = {}
9
+ nav_order_parent_count: dict[str, int] = {}
10
10
 
11
11
  for index, branch in enumerate(config["tree"]):
12
- nav_order_title_tracker = branch.get("parent", branch["title"])
13
- if nav_order_title_tracker not in nav_order_parent_count:
14
- nav_order_parent_count[nav_order_title_tracker] = 0
15
- nav_order_parent_count[nav_order_title_tracker] += 1
12
+ # For nav_order tracking, we need to track by the immediate parent
13
+ # If there's a grand_parent, the parent is the immediate container
14
+ # If there's only a parent, that's the immediate container
15
+ # If neither, it's a top-level item (doesn't need tracking)
16
+ parent = branch.get("parent")
17
+ grand_parent = branch.get("grand_parent")
18
+
19
+ # Determine nav_order based on hierarchy level
20
+ if parent or grand_parent:
21
+ # Child items: track by their immediate parent
22
+ nav_order_title_tracker = parent
23
+ if nav_order_title_tracker not in nav_order_parent_count:
24
+ nav_order_parent_count[nav_order_title_tracker] = 0
25
+ nav_order_parent_count[nav_order_title_tracker] += 1
26
+ nav_order = nav_order_parent_count[nav_order_title_tracker]
27
+ else:
28
+ # Top-level items: use index-based nav_order
29
+ nav_order = index + 2
30
+
16
31
  builder_class = classes.find("import_path=" + branch["builder"]).type
17
32
  builder = builder_class(
18
33
  branch,
19
34
  modules,
20
35
  classes,
21
36
  doc_root,
22
- nav_order=nav_order_parent_count[nav_order_title_tracker] if branch.get("parent") else index + 2,
37
+ nav_order=nav_order,
23
38
  )
24
39
  builder.build()
@@ -30,6 +30,40 @@ class Builder:
30
30
  with output_file.open(mode="w") as doc_file:
31
31
  doc_file.write(doc)
32
32
 
33
+ def make_index_from_class_overview_with_hierarchy(
34
+ self, title_snake_case, source_class, section_folder_path, section_name, parent=None, grand_parent=None
35
+ ):
36
+ """
37
+ Create an index file for a module section with support for nested hierarchy.
38
+
39
+ This method creates the index.md file for a module section, supporting up to 3 levels
40
+ of navigation hierarchy (grand_parent -> parent -> current).
41
+
42
+ Args:
43
+ title_snake_case: The snake-case version of the title for the filename
44
+ source_class: The source class to extract documentation from
45
+ section_folder_path: Path to the section folder
46
+ section_name: The section name for permalink generation
47
+ parent: Optional parent title for 2-level hierarchy
48
+ grand_parent: Optional grand_parent title for 3-level hierarchy
49
+ """
50
+ filename = "index"
51
+ section_folder_path.mkdir(parents=True, exist_ok=True)
52
+
53
+ # Use instance attributes if not provided as arguments
54
+ parent = parent if parent is not None else getattr(self, "parent", None)
55
+ grand_parent = grand_parent if grand_parent is not None else getattr(self, "grand_parent", None)
56
+
57
+ doc = self.build_header(self.title, filename, section_name, parent, self.nav_order, True, grand_parent)
58
+ (elevator_pitch, overview) = self.parse_overview_doc(
59
+ self.raw_docblock_to_md(source_class.doc).lstrip("\n").lstrip(" ")
60
+ )
61
+ doc += f"\n\n# {self.title}\n\n{elevator_pitch}\n\n## Overview\n\n{overview}"
62
+
63
+ output_file = section_folder_path / f"{filename}.md"
64
+ with output_file.open(mode="w") as doc_file:
65
+ doc_file.write(doc)
66
+
33
67
  def parse_overview_doc(self, overview_doc):
34
68
  parts = overview_doc.lstrip("\n").split("\n", 1)
35
69
  if len(parts) < 2:
@@ -105,7 +139,7 @@ class Builder:
105
139
  self._attribute_cache[source_class.source_file] = doc_strings
106
140
  return doc_strings
107
141
 
108
- def build_header(self, title, filename, section_name, parent, nav_order, has_children):
142
+ def build_header(self, title, filename, section_name, parent, nav_order, has_children, grand_parent=None):
109
143
  permalink = "/docs/" + (f"{section_name}/" if section_name else "") + f"{filename}.html"
110
144
  header = f"""---
111
145
  layout: default
@@ -113,6 +147,8 @@ title: {title}
113
147
  permalink: {permalink}
114
148
  nav_order: {nav_order}
115
149
  """
150
+ if grand_parent:
151
+ header += f"grand_parent: {grand_parent}\n"
116
152
  if parent:
117
153
  header += f"parent: {parent}\n"
118
154
  if has_children:
@@ -11,14 +11,43 @@ class Module(Builder):
11
11
  super().__init__(branch, modules, classes, doc_root, nav_order)
12
12
  self.class_list = branch["classes"]
13
13
  self.args_to_additional_attributes_map = branch.get("args_to_additional_attributes_map", {})
14
+ self.parent = branch.get("parent", False)
15
+ self.grand_parent = branch.get("grand_parent", False)
14
16
 
15
17
  def build(self):
16
18
  title_snake_case = clearskies.functional.string.title_case_to_snake_case(self.title.replace(" ", "")).replace(
17
19
  "_", "-"
18
20
  )
19
- section_folder_path = self.doc_root / title_snake_case
21
+
22
+ # Determine the section folder path based on hierarchy
23
+ if self.grand_parent:
24
+ # Three-level hierarchy: grand_parent/parent/title/
25
+ grand_parent_snake = (
26
+ clearskies.functional.string.title_case_to_snake_case(self.grand_parent)
27
+ .replace("_", "-")
28
+ .replace(" ", "")
29
+ )
30
+ parent_snake = (
31
+ clearskies.functional.string.title_case_to_snake_case(self.parent).replace("_", "-").replace(" ", "")
32
+ )
33
+ section_name = f"{grand_parent_snake}/{parent_snake}/{title_snake_case}"
34
+ section_folder_path = self.doc_root / grand_parent_snake / parent_snake / title_snake_case
35
+ elif self.parent:
36
+ # Two-level hierarchy: parent/title/
37
+ parent_snake = (
38
+ clearskies.functional.string.title_case_to_snake_case(self.parent).replace("_", "-").replace(" ", "")
39
+ )
40
+ section_name = f"{parent_snake}/{title_snake_case}"
41
+ section_folder_path = self.doc_root / parent_snake / title_snake_case
42
+ else:
43
+ # Top-level: title/
44
+ section_name = title_snake_case
45
+ section_folder_path = self.doc_root / title_snake_case
46
+
20
47
  source_class = self.classes.find(f"import_path={self.source}")
21
- self.make_index_from_class_overview(title_snake_case, source_class, section_folder_path)
48
+ self.make_index_from_class_overview_with_hierarchy(
49
+ title_snake_case, source_class, section_folder_path, section_name
50
+ )
22
51
 
23
52
  default_args = self.default_args()
24
53
 
@@ -28,7 +57,12 @@ class Module(Builder):
28
57
  source_class = self.classes.find(f"import_path={class_name}")
29
58
  title = source_class.name
30
59
  filename = clearskies.functional.string.title_case_to_snake_case(source_class.name).replace("_", "-")
31
- class_doc = self.build_header(source_class.name, filename, title_snake_case, self.title, nav_order, False)
60
+ # For classes within a module, the module title becomes the parent
61
+ # and if the module has a parent, that becomes the grand_parent
62
+ class_grand_parent = self.parent if self.parent else None
63
+ class_doc = self.build_header(
64
+ source_class.name, filename, section_name, self.title, nav_order, False, class_grand_parent
65
+ )
32
66
  (elevator_pitch, overview) = self.parse_overview_doc(
33
67
  self.raw_docblock_to_md(source_class.doc).lstrip("\n").lstrip(" ")
34
68
  )
@@ -12,21 +12,44 @@ class SingleClass(Builder):
12
12
  self.additional_attribute_sources = branch.get("additional_attribute_sources", [])
13
13
  self.args_to_additional_attributes_map = branch.get("args_to_additional_attributes_map", {})
14
14
  self.parent = branch.get("parent", False)
15
+ self.grand_parent = branch.get("grand_parent", False)
15
16
 
16
17
  def build(self):
17
- section_name = (
18
- clearskies.functional.string.title_case_to_snake_case(self.parent if self.parent else self.title)
19
- .replace("_", "-")
20
- .replace(" ", "")
21
- )
22
- section_folder_path = self.doc_root / section_name
23
- section_folder_path.mkdir(exist_ok=True)
18
+ # Determine the section folder path based on hierarchy
19
+ if self.grand_parent:
20
+ # Three-level hierarchy: grand_parent/parent/file.md
21
+ grand_parent_snake = (
22
+ clearskies.functional.string.title_case_to_snake_case(self.grand_parent)
23
+ .replace("_", "-")
24
+ .replace(" ", "")
25
+ )
26
+ parent_snake = (
27
+ clearskies.functional.string.title_case_to_snake_case(self.parent).replace("_", "-").replace(" ", "")
28
+ )
29
+ section_name = f"{grand_parent_snake}/{parent_snake}"
30
+ section_folder_path = self.doc_root / grand_parent_snake / parent_snake
31
+ elif self.parent:
32
+ # Two-level hierarchy: parent/file.md
33
+ section_name = (
34
+ clearskies.functional.string.title_case_to_snake_case(self.parent).replace("_", "-").replace(" ", "")
35
+ )
36
+ section_folder_path = self.doc_root / section_name
37
+ else:
38
+ # Top-level: title/index.md
39
+ section_name = (
40
+ clearskies.functional.string.title_case_to_snake_case(self.title).replace("_", "-").replace(" ", "")
41
+ )
42
+ section_folder_path = self.doc_root / section_name
43
+
44
+ section_folder_path.mkdir(parents=True, exist_ok=True)
24
45
  source_class = self.classes.find(f"import_path={self.source}")
25
46
 
26
47
  title_snake_case = clearskies.functional.string.title_case_to_snake_case(self.title.replace(" ", "")).replace(
27
48
  "_", "-"
28
49
  )
29
- class_doc = self.build_header(self.title, title_snake_case, section_name, self.parent, self.nav_order, False)
50
+ class_doc = self.build_header(
51
+ self.title, title_snake_case, section_name, self.parent, self.nav_order, False, self.grand_parent
52
+ )
30
53
  (elevator_pitch, overview) = self.parse_overview_doc(
31
54
  self.raw_docblock_to_md(source_class.doc).lstrip("\n").lstrip(" ")
32
55
  )
@@ -70,10 +93,17 @@ class SingleClass(Builder):
70
93
 
71
94
  class_doc += f"{table_of_contents}\n{main_doc}"
72
95
 
73
- output_file = section_folder_path / (
74
- "index.md"
75
- if not self.parent
76
- else clearskies.functional.string.title_case_to_snake_case(self.title.replace(" ", "")) + ".md"
77
- )
96
+ # Determine output filename based on hierarchy level
97
+ if self.parent or self.grand_parent:
98
+ # Child or grandchild: use title as filename
99
+ output_filename = (
100
+ clearskies.functional.string.title_case_to_snake_case(self.title.replace(" ", "")).replace("_", "-")
101
+ + ".md"
102
+ )
103
+ else:
104
+ # Top-level: use index.md
105
+ output_filename = "index.md"
106
+
107
+ output_file = section_folder_path / output_filename
78
108
  with output_file.open(mode="w") as doc_file:
79
109
  doc_file.write(class_doc)
@@ -1,40 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: clear-skies-doc-builder
3
- Version: 2.0.5
4
- Summary: The docbuilder for all 'official' clearskies plugins (as well as the main clearskies docs)
5
- Project-URL: repository, https://github.com/clearskies-py/docs
6
- Project-URL: issues, https://github.com/clearskies-py/docs/issues
7
- Project-URL: changelog, https://github.com/clearskies-py/docs/blob/main/CHANGELOG.md
8
- Author-email: Conor Mancone <cmancone@gmail.com>
9
- License-Expression: MIT
10
- License-File: LICENSE
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Requires-Python: <4.0,>=3.11
16
- Requires-Dist: clear-skies<3.0.0,>=2.0.0
17
- Provides-Extra: dev
18
- Requires-Dist: types-requests>=2.32.4; extra == 'dev'
19
- Description-Content-Type: text/markdown
20
-
21
- # docs
22
-
23
- The documentation builder for clearskies and related plugins
24
-
25
- ## Overview
26
-
27
- Each "official" clearskies module (including the core clearskies library itself) has the documentation primarily written in the codebase as docblocks. The documentation site is then built by extracting these docblocks and stitching them together. To be clear, this isn't about the low-level "API" documentation that describes every single class/method in the framework. Rather, this is about the primary documentation site itself (clearskies.info) which is focused on high-level use cases and examples of the primary configuration options. As a result, it's not a simple matter of just iterating over the classes/methods and building documentation. To build a coherent documentation site, each plugin has a configuration file that basically outlines the final "structure" or organization of the resulting documentation, as well as the name of a builder class that will combine that configuration information with the codebase itself to create the actual docs.
28
-
29
- The docs themselves (in the source code) are all written with markdown. This documentation builder then takes that markdwon and adds the necessary headers/etc so to make them valid files for [Jekyll](https://jekyllrb.com/), the builder for the current documentation site. The site itself is hosted in S3, so building an actual documentation site means:
30
-
31
- 1. Properly documenting everything inside of the source code via markdown.
32
- 2. Creating a config file (`docs/python/config.json`) to map source code docs to Jekyll files.
33
- 3. Creating a skeleton of a Jekyll site in the `doc/jekyll` folder of the plugin.
34
- 4. Installing this doc builder via `poetry add clear-skies-doc-builder`.
35
- 5. Run the doc builder.
36
- 6. Build with Jekyll.
37
- 7. Push to the appropriate subfolder via S3.
38
- 8. (Only once) Update the main clearskies doc site to know about the new subfolder for this plugin.
39
-
40
- Of course, we want the Jekyll sites to be consistent with eachother in terms of style/look. In the long run we'll probably have this doc builder also bootstrap the Jekyll site, but for now you just have to manually setup the Jekyll build using the main clearskies repo as a template.