mkdocs-apidescribed-plugin 0.1.0__tar.gz → 0.2.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.

Potentially problematic release.


This version of mkdocs-apidescribed-plugin might be problematic. Click here for more details.

Files changed (30) hide show
  1. mkdocs_apidescribed_plugin-0.2.0/.github/workflows/python-package.yml +33 -0
  2. mkdocs_apidescribed_plugin-0.2.0/CHANGELOG +15 -0
  3. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/PKG-INFO +1 -1
  4. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/docs/index.md +4 -4
  5. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/docs/showcase.md +1 -1
  6. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/mkdocs.yml +9 -6
  7. mkdocs_apidescribed_plugin-0.2.0/src/mkdocs_apidescribed/__init__.py +2 -0
  8. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/src/mkdocs_apidescribed/config.py +4 -2
  9. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/src/mkdocs_apidescribed/extension.py +7 -1
  10. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/src/mkdocs_apidescribed/formatter.py +13 -8
  11. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/src/mkdocs_apidescribed/inspector.py +18 -3
  12. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/src/mkdocs_apidescribed/probe.py +1 -1
  13. mkdocs_apidescribed_plugin-0.1.0/CHANGELOG +0 -8
  14. mkdocs_apidescribed_plugin-0.1.0/src/mkdocs_apidescribed/__init__.py +0 -2
  15. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/.coveragerc +0 -0
  16. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/.gitignore +0 -0
  17. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/.readthedocs.yaml +0 -0
  18. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/AUTHORS +0 -0
  19. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/CONTRIBUTING +0 -0
  20. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/INSTALL +0 -0
  21. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/LICENSE +0 -0
  22. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/README.md +0 -0
  23. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/docs/config.md +0 -0
  24. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/pyproject.toml +0 -0
  25. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/src/mkdocs_apidescribed/parsers.py +0 -0
  26. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/src/mkdocs_apidescribed/plugin.py +0 -0
  27. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/tests/__init__.py +0 -0
  28. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/tests/test_module.py +0 -0
  29. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/tools/buildme.py +0 -0
  30. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-0.2.0}/uv.lock +0 -0
@@ -0,0 +1,33 @@
1
+ name: Python package
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ build:
12
+
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python-version: ["3.10", 3.11, 3.12]
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+ - name: Install deps
26
+ run: |
27
+ python -m pip install pytest coverage coveralls mkdocs-material
28
+ - name: Run tests
29
+ env:
30
+ GITHUB_TOKEN: ${{ secrets.github_token }}
31
+ run: |
32
+ coverage run --source=src/mkdocs_apidescribed -m pytest
33
+ coveralls --service=github
@@ -0,0 +1,15 @@
1
+ mkdocs-apidescribed-plugin changelog
2
+ ====================================
3
+
4
+
5
+ v0.2.0 [2025-05-11]
6
+ -------------------
7
+ + Add 'inherited' filter option.
8
+ + Show class bases.
9
+ * Fix autolinks behaviour.
10
+ * Fix more >7th level headings.
11
+
12
+
13
+ v0.1.0 [2025-05-09]
14
+ -------------------
15
+ + Basic functionality.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-apidescribed-plugin
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: mkdocs plugin to generate API documentation for Python programs
5
5
  Project-URL: Homepage, https://github.com/idlesign/mkdocs-apidescribed-plugin
6
6
  Project-URL: Documentation, https://mkdocs-apidescribed-plugin.readthedocs.org/
@@ -35,12 +35,12 @@ pip install mkdocs-apidescribed-plugin
35
35
  markdown_extensions:
36
36
  - mkdocs_apidescribed.extension # this is our extention
37
37
  - admonition # nice admonitions
38
- - pymdownx.superfences
39
- - pymdownx.details # collapsible blocks
40
38
  - md_in_html # for proper indentation
39
+ - pymdownx.details # collapsible blocks
41
40
  - pymdownx.emoji: # for icons
42
- emoji_index: !!python/name:material.extensions.emoji.twemoji
43
- emoji_generator: !!python/name:material.extensions.emoji.to_svg
41
+ emoji_index: !!python/name:material.extensions.emoji.twemoji
42
+ emoji_generator: !!python/name:material.extensions.emoji.to_svg
43
+ - pymdownx.superfences
44
44
 
45
45
  ```
46
46
 
@@ -9,7 +9,7 @@ Let's document module ``mkdocs_apidescribed.probe``.
9
9
  - "_*"
10
10
  - "*ignore*"
11
11
  ```
12
- **Below is automated documentation below.**
12
+ **Below is an automated documentation sample.**
13
13
 
14
14
  ----
15
15
 
@@ -21,6 +21,7 @@ theme:
21
21
  features:
22
22
  - navigation.top
23
23
  - toc.follow
24
+ - content.action.view
24
25
  - content.action.edit
25
26
  - content.code.copy
26
27
  - content.code.annotate
@@ -28,6 +29,12 @@ theme:
28
29
  markdown_extensions:
29
30
  - mkdocs_apidescribed.extension
30
31
  - admonition
32
+ - attr_list
33
+ - md_in_html
34
+ - pymdownx.details
35
+ - pymdownx.emoji:
36
+ emoji_index: !!python/name:material.extensions.emoji.twemoji
37
+ emoji_generator: !!python/name:material.extensions.emoji.to_svg
31
38
  - pymdownx.highlight:
32
39
  anchor_linenums: true
33
40
  line_spans: __span
@@ -35,9 +42,5 @@ markdown_extensions:
35
42
  - pymdownx.inlinehilite
36
43
  - pymdownx.snippets
37
44
  - pymdownx.superfences
38
- - pymdownx.details
39
- - attr_list
40
- - md_in_html
41
- - pymdownx.emoji:
42
- emoji_index: !!python/name:material.extensions.emoji.twemoji
43
- emoji_generator: !!python/name:material.extensions.emoji.to_svg
45
+ - toc:
46
+ permalink: true
@@ -0,0 +1,2 @@
1
+
2
+ VERSION = '0.2.0'
@@ -26,14 +26,16 @@ DEFAULT_CONFIG = {
26
26
  'func': ':material-function:', # for functions
27
27
  'cls': ':material-delta:', # for classes
28
28
  'property': ':material-alpha-p-box-outline:', # for class properties
29
- 'classmethod': ':material-alpha-c-box-outline:', # for class properties
30
- 'staticmethod': ':material-alpha-s-box-outline:', # for class properties
29
+ 'classmethod': ':material-alpha-c-box-outline:', # for class methods
30
+ 'staticmethod': ':material-alpha-s-box-outline:', # for static methods
31
31
  'inherited': ':material-subdirectory-arrow-left:', # for class inherited items
32
+ 'clsbases': ':material-alpha-b-box:', # for base classes
32
33
  'raises': ':material-lightning-bolt:', # for descriptions of raised exceptions
33
34
  'returns': ':material-arrow-right-thin:', # for descriptions of returned value
34
35
  },
35
36
 
36
37
  'undocumented': False, # describe items without docstrings
38
+ 'inherited': True, # describe inherited items (e.g. from parent classes)
37
39
  'types': [
38
40
  # symbol types to describe (order respected)
39
41
  'attributes',
@@ -23,7 +23,13 @@ class ApidescribedProcessor(Preprocessor):
23
23
  out = []
24
24
  last_type = ''
25
25
 
26
- root, symbols = inspect(target, types=config['types'], ignore=config['ignore'], only=config['only'])
26
+ root, symbols = inspect(
27
+ target,
28
+ types=config['types'],
29
+ ignore=config['ignore'],
30
+ only=config['only'],
31
+ inherited=config['inherited'],
32
+ )
27
33
  formatter = cls_fmt(symbol=root, config=config)
28
34
 
29
35
  if prolog := formatter.run():
@@ -12,9 +12,10 @@ from .parsers import DocstrParser, Block
12
12
  log = get_plugin_logger(__name__)
13
13
 
14
14
  RE_LINK = re.compile(
15
- r'https?://(www\.)?[A-z0-9@:%.-_+~#=]{1,256}\.[A-z0-9()]{1,6}\b([A-z0-9()@:%-_+.~#?&/=]*)'
15
+ r'https?://(www\.)?[A-z0-9@:%.\-_+~#=]{1,256}\.[A-z0-9()]{1,6}\b([A-z0-9()@:%\-_+.~#?&/=]*)'
16
16
  )
17
17
 
18
+ # todo link to src in repo
18
19
 
19
20
  class Formatter:
20
21
 
@@ -22,13 +23,14 @@ class Formatter:
22
23
  SymbolType.attr: 'Attributes',
23
24
  SymbolType.func: 'Functions',
24
25
  SymbolType.cls: 'Classes',
26
+ SymbolType.module: 'Modules',
25
27
  }
26
28
 
27
29
  @classmethod
28
30
  def format_error(cls, exc: Exception, *, instruction: list[str], debug: bool = False) -> str:
29
31
 
30
32
  def indent_raw(val: str) -> str:
31
- return f' ```\n{indent(val, prefix=' ')}\n ```\n'
33
+ return f' ```\n{indent(val, prefix=" ")}\n ```\n'
32
34
 
33
35
  lines = [
34
36
  f'??? failure "Automated documentation error: {exc.__class__.__name__}"',
@@ -217,12 +219,17 @@ class Formatter:
217
219
 
218
220
  def format_description(self) -> str:
219
221
  docstring = self.docstr
222
+ symbol = self.symbol
223
+ icons = self.config['icons']
220
224
 
221
225
  text = docstring.text
222
226
 
223
- text = f'{text}\n'
227
+ prefix = ''
228
+ if symbol.type == SymbolType.cls:
229
+ if bases := [f'[``{base.name}``](#{base.name.lower()})' for base in symbol.raw.bases]:
230
+ prefix = f'{icons["clsbases"]} {" ".join(bases)}\n\n'
224
231
 
225
- icons = self.config['icons']
232
+ text = f'{prefix}{text}\n'
226
233
 
227
234
  if raised := docstring.raises:
228
235
  raises = '\n\n'.join(
@@ -259,10 +266,8 @@ class Formatter:
259
266
  if symbol.is_staticmethod:
260
267
  icons_after.append(icons['staticmethod'])
261
268
 
262
- title = (
263
- f'{"#" * (self.heading_level + symbol.depth)} '
264
- f'{icon_before} {symbol.name} {" ".join(icons_after)}\n'
265
- )
269
+ heading_marker = f'{"#" * (self.heading_level + symbol.depth)} '[:7] # 7th level max
270
+ title = f'{heading_marker}{icon_before} {symbol.name} {" ".join(icons_after)}\n'
266
271
 
267
272
  return title
268
273
 
@@ -71,6 +71,7 @@ def get_symbol(
71
71
  undocumented: bool = False,
72
72
  ignore: list[str] = None,
73
73
  only: set[str] = None,
74
+ inherited: bool = True,
74
75
  depth: int = 0,
75
76
  ) -> tuple[Symbol, list[Symbol]] | None:
76
77
 
@@ -101,6 +102,7 @@ def get_symbol(
101
102
  undocumented=undocumented,
102
103
  ignore=ignore,
103
104
  only=only,
105
+ inherited=inherited,
104
106
  depth=depth + 1
105
107
  )
106
108
 
@@ -132,7 +134,8 @@ def get_symbols(
132
134
  undocumented: bool = False,
133
135
  ignore: list[str] = None,
134
136
  only: set[str] = None,
135
- depth: int = 0
137
+ inherited: bool = True,
138
+ depth: int = 0,
136
139
  ) -> list[Symbol]:
137
140
 
138
141
  symbols = []
@@ -153,6 +156,9 @@ def get_symbols(
153
156
  docstring = symbol_raw.docstring
154
157
  skip = False
155
158
 
159
+ if not inherited and symbol_raw.inherited:
160
+ continue
161
+
156
162
  if docstring is None and not undocumented:
157
163
  continue
158
164
 
@@ -174,6 +180,7 @@ def get_symbols(
174
180
  undocumented=undocumented,
175
181
  ignore=ignore,
176
182
  only=only,
183
+ inherited=inherited,
177
184
  depth=depth,
178
185
  )
179
186
 
@@ -193,13 +200,21 @@ def inspect(
193
200
  types: list[str],
194
201
  undocumented: bool = False,
195
202
  ignore: list[str],
196
- only: list[str]
203
+ only: list[str],
204
+ inherited: bool,
197
205
  ) -> tuple[Symbol, list[Symbol]]:
198
206
 
199
207
  log.info(f'Getting API information for: {target} ...')
200
208
  obj = griffe.load(target)
201
209
 
202
210
  root, _ = get_symbol(obj)
203
- symbols = get_symbols(obj, types=types, undocumented=undocumented, ignore=ignore, only=set(only))
211
+ symbols = get_symbols(
212
+ obj,
213
+ types=types,
214
+ undocumented=undocumented,
215
+ ignore=ignore,
216
+ only=set(only),
217
+ inherited=inherited,
218
+ )
204
219
 
205
220
  return root, symbols
@@ -157,7 +157,7 @@ class MyBaseClass:
157
157
  return True
158
158
 
159
159
 
160
- class MySubClass(MyBaseClass):
160
+ class MySubClass(MyBaseClass, list):
161
161
  """Sub class description."""
162
162
 
163
163
  sub_attr = "sub_attr value"
@@ -1,8 +0,0 @@
1
- mkdocs-apidescribed-plugin changelog
2
- =================================
3
-
4
-
5
- Unreleased
6
- ----------
7
- + Basic functionality.
8
-
@@ -1,2 +0,0 @@
1
-
2
- VERSION = '0.1.0'