mkdocs-apidescribed-plugin 0.1.0__tar.gz → 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.
Files changed (28) hide show
  1. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-1.0.0}/PKG-INFO +1 -1
  2. mkdocs_apidescribed_plugin-1.0.0/mkdocs_apidescribed/__init__.py +2 -0
  3. {mkdocs_apidescribed_plugin-0.1.0/src → mkdocs_apidescribed_plugin-1.0.0}/mkdocs_apidescribed/config.py +4 -2
  4. {mkdocs_apidescribed_plugin-0.1.0/src → mkdocs_apidescribed_plugin-1.0.0}/mkdocs_apidescribed/extension.py +7 -1
  5. {mkdocs_apidescribed_plugin-0.1.0/src → mkdocs_apidescribed_plugin-1.0.0}/mkdocs_apidescribed/formatter.py +13 -8
  6. {mkdocs_apidescribed_plugin-0.1.0/src → mkdocs_apidescribed_plugin-1.0.0}/mkdocs_apidescribed/inspector.py +18 -3
  7. {mkdocs_apidescribed_plugin-0.1.0/src → mkdocs_apidescribed_plugin-1.0.0}/mkdocs_apidescribed/probe.py +4 -4
  8. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-1.0.0}/pyproject.toml +30 -1
  9. mkdocs_apidescribed_plugin-0.1.0/.coveragerc +0 -3
  10. mkdocs_apidescribed_plugin-0.1.0/.readthedocs.yaml +0 -12
  11. mkdocs_apidescribed_plugin-0.1.0/AUTHORS +0 -18
  12. mkdocs_apidescribed_plugin-0.1.0/CHANGELOG +0 -8
  13. mkdocs_apidescribed_plugin-0.1.0/CONTRIBUTING +0 -25
  14. mkdocs_apidescribed_plugin-0.1.0/INSTALL +0 -27
  15. mkdocs_apidescribed_plugin-0.1.0/docs/config.md +0 -25
  16. mkdocs_apidescribed_plugin-0.1.0/docs/index.md +0 -71
  17. mkdocs_apidescribed_plugin-0.1.0/docs/showcase.md +0 -33
  18. mkdocs_apidescribed_plugin-0.1.0/mkdocs.yml +0 -43
  19. mkdocs_apidescribed_plugin-0.1.0/src/mkdocs_apidescribed/__init__.py +0 -2
  20. mkdocs_apidescribed_plugin-0.1.0/tests/__init__.py +0 -0
  21. mkdocs_apidescribed_plugin-0.1.0/tests/test_module.py +0 -3
  22. mkdocs_apidescribed_plugin-0.1.0/tools/buildme.py +0 -13
  23. mkdocs_apidescribed_plugin-0.1.0/uv.lock +0 -648
  24. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-1.0.0}/.gitignore +0 -0
  25. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-1.0.0}/LICENSE +0 -0
  26. {mkdocs_apidescribed_plugin-0.1.0 → mkdocs_apidescribed_plugin-1.0.0}/README.md +0 -0
  27. {mkdocs_apidescribed_plugin-0.1.0/src → mkdocs_apidescribed_plugin-1.0.0}/mkdocs_apidescribed/parsers.py +0 -0
  28. {mkdocs_apidescribed_plugin-0.1.0/src → mkdocs_apidescribed_plugin-1.0.0}/mkdocs_apidescribed/plugin.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-apidescribed-plugin
3
- Version: 0.1.0
3
+ Version: 1.0.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/
@@ -0,0 +1,2 @@
1
+
2
+ VERSION = '1.0.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
@@ -20,7 +20,7 @@ ENVIRON = environ
20
20
  """Alias description."""
21
21
 
22
22
 
23
- def undocumented():
23
+ def undocumented(): # pragma: nocover
24
24
  pass
25
25
 
26
26
 
@@ -152,12 +152,12 @@ class MyBaseClass:
152
152
  def __str__(self):
153
153
  """Specialized. To string."""
154
154
 
155
- def method_a(self, a=1):
155
+ def method_a(self, a=1): # pragma: nocover
156
156
  """Base method_a description."""
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"
@@ -169,6 +169,6 @@ class MySubClass(MyBaseClass):
169
169
  a: str,
170
170
  b: int,
171
171
  d: float,
172
- ) -> str:
172
+ ) -> str: # pragma: nocover
173
173
  """Sub method_sub_b description."""
174
174
  return ''
@@ -25,11 +25,24 @@ Documentation = "https://mkdocs-apidescribed-plugin.readthedocs.org/"
25
25
 
26
26
  [dependency-groups]
27
27
  dev = [
28
+ {include-group = "docs"},
29
+ {include-group = "linters"},
30
+ {include-group = "tests"},
31
+ ]
32
+ docs = [
28
33
  "mkdocs",
29
34
  "mkdocs-material",
30
- "pytest",
35
+ ]
36
+ linters = [
31
37
  "ruff",
32
38
  ]
39
+ tests = [
40
+ "pytest",
41
+ "pytest-cov",
42
+ "pytest-datafixtures",
43
+ "coverage",
44
+ ]
45
+
33
46
 
34
47
  [build-system]
35
48
  requires = ["hatchling"]
@@ -40,3 +53,19 @@ path = "src/mkdocs_apidescribed/__init__.py"
40
53
 
41
54
  [tool.hatch.build.targets.wheel]
42
55
  packages = ["src/mkdocs_apidescribed"]
56
+
57
+ [tool.hatch.build.targets.sdist]
58
+ packages = ["src/mkdocs_apidescribed"]
59
+
60
+ [tool.coverage.run]
61
+ source = [
62
+ "src/",
63
+ ]
64
+ omit = []
65
+
66
+ [tool.coverage.report]
67
+ fail_under = 98.00
68
+ exclude_also = [
69
+ "raise NotImplementedError",
70
+ "if TYPE_CHECKING:",
71
+ ]
@@ -1,3 +0,0 @@
1
- [run]
2
- source = src/
3
-
@@ -1,12 +0,0 @@
1
- version: 2
2
-
3
- build:
4
- os: "ubuntu-24.04"
5
- tools:
6
- python: "3"
7
- jobs:
8
- pre_install:
9
- - pip install mkdocs-material mkdocs-apidescribed-plugin
10
-
11
- mkdocs:
12
- configuration: mkdocs.yml
@@ -1,18 +0,0 @@
1
- mkdocs-apidescribed-plugin authors
2
- ===============================
3
-
4
- Created by Igor `idle sign` Starikov.
5
-
6
-
7
- Contributors
8
- ------------
9
-
10
- Here could be your name.
11
-
12
-
13
-
14
- Translators
15
- -----------
16
-
17
- Here could be your name.
18
-
@@ -1,8 +0,0 @@
1
- mkdocs-apidescribed-plugin changelog
2
- =================================
3
-
4
-
5
- Unreleased
6
- ----------
7
- + Basic functionality.
8
-
@@ -1,25 +0,0 @@
1
- mkdocs-apidescribed-plugin contributing
2
- ====================================
3
-
4
-
5
- Submit issues
6
- -------------
7
-
8
- If you spotted something weird in application behavior or want to propose a feature you are welcome.
9
-
10
-
11
- Write code
12
- ----------
13
- If you are eager to participate in application development and to work on an existing issue (whether it should
14
- be a bugfix or a feature implementation), fork, write code, and make a pull request right from the forked project page.
15
-
16
-
17
- Spread the word
18
- ---------------
19
-
20
- If you have some tips and tricks or any other words that you think might be of interest for the others — publish it
21
- wherever you find convenient.
22
-
23
-
24
- See also: https://github.com/idlesign/mkdocs-apidescribed-plugin
25
-
@@ -1,27 +0,0 @@
1
- mkdocs-apidescribed-plugin installation
2
- ====================================
3
-
4
-
5
- Python ``pip`` package is required to install ``mkdocs-apidescribed-plugin``.
6
-
7
-
8
- From sources
9
- ------------
10
-
11
- Use the following command line to install ``mkdocs-apidescribed-plugin`` from sources directory (containing setup.py):
12
-
13
- pip install .
14
-
15
-
16
- From PyPI
17
- ---------
18
-
19
- Alternatively you can install ``mkdocs-apidescribed-plugin`` from PyPI:
20
-
21
- pip install mkdocs-apidescribed-plugin
22
-
23
-
24
- Use `-U` flag for upgrade:
25
-
26
- pip install -U mkdocs-apidescribed-plugin
27
-
@@ -1,25 +0,0 @@
1
- # Configuration
2
-
3
- To configure ``apidescribed`` one can use yaml just after ``::: apidescribed: `` directive:
4
-
5
- ```
6
- ::: apidescribed: mkdocs_apidescribed.config
7
- debug: true
8
- categorize: false
9
- only:
10
- - DEFAULT_CONFIG
11
- location:
12
- mode: module
13
- ```
14
-
15
- ----
16
-
17
- **All available configuration options are listed below:**
18
-
19
- ::: apidescribed: mkdocs_apidescribed.config
20
- debug: true
21
- categorize: false
22
- only:
23
- - DEFAULT_CONFIG
24
- location:
25
- mode: module
@@ -1,71 +0,0 @@
1
- # Introduction
2
-
3
- *mkdocs plugin to generate API documentation for Python programs*
4
-
5
- * Made to autodocument Python code
6
- * Plays well with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/)
7
- * Configurable
8
- * Easy to use
9
-
10
- !!! tip
11
- See demo in ``Showcase`` section.
12
-
13
- ## Requirements
14
-
15
- 1. Python 3.10+
16
- 2. `mkdocs` package
17
-
18
- ## Installation
19
-
20
- ``` shell
21
- pip install mkdocs-apidescribed-plugin
22
- ```
23
-
24
- ## Configuration
25
-
26
- 1. Add ``apidescribed`` into ``mkdocs.yml``:
27
-
28
- ```yaml title="mkdocs.yml"
29
- theme:
30
- ...
31
- features:
32
- ...
33
- - content.code.annotate # for parameter descriptions
34
-
35
- markdown_extensions:
36
- - mkdocs_apidescribed.extension # this is our extention
37
- - admonition # nice admonitions
38
- - pymdownx.superfences
39
- - pymdownx.details # collapsible blocks
40
- - md_in_html # for proper indentation
41
- - pymdownx.emoji: # for icons
42
- emoji_index: !!python/name:material.extensions.emoji.twemoji
43
- emoji_generator: !!python/name:material.extensions.emoji.to_svg
44
-
45
- ```
46
-
47
- 2. Add ``::: apidescribed:`` directive into your documentation followed by a module path:
48
-
49
- ```md title="index.md"
50
- This is my documentation
51
-
52
- ::: apidescribed: somepackage.somemodule
53
-
54
- ```
55
-
56
-
57
- ## Get involved into mkdocs-apidescribed
58
-
59
- !!! success "Submit issues"
60
- If you spotted something weird in application behavior or want to propose a feature you can do
61
- that at <https://github.com/idlesign/mkdocs-apidescribed-plugin/issues>
62
-
63
- !!! tip "Write code"
64
- If you are eager to participate in application development,
65
- fork it at <https://github.com/idlesign/mkdocs-apidescribed-plugin>, write
66
- your code, whether it should be a bugfix or a feature implementation,
67
- and make a pull request right from the forked project page.
68
-
69
- !!! info "Spread the word"
70
- If you have some tips and tricks or any other words in mind that
71
- you think might be of interest for the others --- publish it.
@@ -1,33 +0,0 @@
1
- # Showcase
2
-
3
- Let's document module ``mkdocs_apidescribed.probe``.
4
-
5
- ```
6
- ::: apidescribed: mkdocs_apidescribed.probe
7
- debug: true
8
- ignore:
9
- - "_*"
10
- - "*ignore*"
11
- ```
12
- **Below is automated documentation below.**
13
-
14
- ----
15
-
16
- ::: apidescribed: mkdocs_apidescribed.probe
17
- debug: true
18
- ignore:
19
- - "_*"
20
- - "*ignore*"
21
-
22
- ## Error example
23
-
24
- Now let's try to document an unknown module ``somepackage.somemodule``,
25
- using ``debug: true`` option for troubleshooting:
26
-
27
- ```
28
- ::: apidescribed: somepackage.somemodule
29
- debug: true
30
- ```
31
-
32
- ::: apidescribed: somepackage.somemodule
33
- debug: true
@@ -1,43 +0,0 @@
1
- site_name: mkdocs-apidescribed
2
- site_url: !ENV READTHEDOCS_CANONICAL_URL
3
-
4
- copyright: Copyright &copy; 2025, Igor Starikov
5
-
6
- repo_url: https://github.com/idlesign/mkdocs-apidescribed-plugin
7
- edit_uri: edit/master/docs/
8
-
9
- extra:
10
- social:
11
- - icon: fontawesome/brands/github
12
- link: https://github.com/idlesign
13
-
14
- plugins:
15
- - search
16
-
17
- theme:
18
- name: material
19
- palette:
20
- primary: green
21
- features:
22
- - navigation.top
23
- - toc.follow
24
- - content.action.edit
25
- - content.code.copy
26
- - content.code.annotate
27
-
28
- markdown_extensions:
29
- - mkdocs_apidescribed.extension
30
- - admonition
31
- - pymdownx.highlight:
32
- anchor_linenums: true
33
- line_spans: __span
34
- pygments_lang_class: true
35
- - pymdownx.inlinehilite
36
- - pymdownx.snippets
37
- - 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
@@ -1,2 +0,0 @@
1
-
2
- VERSION = '0.1.0'
File without changes
@@ -1,3 +0,0 @@
1
-
2
- def test_me():
3
- assert True
@@ -1,13 +0,0 @@
1
- import os
2
-
3
- from mkdocs.commands import build
4
- from mkdocs import config
5
-
6
- os.chdir('../')
7
-
8
- cfg = config.load_config()
9
- cfg.plugins.on_startup(command='build', dirty=False)
10
- try:
11
- build.build(cfg)
12
- finally:
13
- cfg.plugins.on_shutdown()