mkdocstrings-typescript 0.0.0__tar.gz → 0.0.1__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.
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2023, Timothée Mazzucotelli
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.1
2
+ Name: mkdocstrings-typescript
3
+ Version: 0.0.1
4
+ Summary: A Typescript handler for mkdocstrings.
5
+ Author-Email: =?utf-8?q?Timoth=C3=A9e_Mazzucotelli?= <dev@pawamoy.fr>
6
+ License: ISC
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Documentation
19
+ Classifier: Topic :: Software Development
20
+ Classifier: Topic :: Utilities
21
+ Classifier: Typing :: Typed
22
+ Project-URL: Homepage, https://mkdocstrings.github.io/typescript
23
+ Project-URL: Documentation, https://mkdocstrings.github.io/typescript
24
+ Project-URL: Changelog, https://mkdocstrings.github.io/typescript/changelog
25
+ Project-URL: Repository, https://github.com/mkdocstrings/typescript
26
+ Project-URL: Issues, https://github.com/mkdocstrings/typescript/issues
27
+ Project-URL: Discussions, https://github.com/mkdocstrings/typescript/discussions
28
+ Project-URL: Gitter, https://gitter.im/mkdocstrings/typescript
29
+ Project-URL: Funding, https://github.com/sponsors/pawamoy
30
+ Requires-Python: >=3.8
31
+ Requires-Dist: mkdocstrings>=0.24
32
+ Requires-Dist: griffe-typedoc>=0.0
33
+ Description-Content-Type: text/markdown
34
+
35
+ # mkdocstrings-typescript
36
+
37
+ [![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://mkdocstrings.github.io/typescript/)
38
+ [![gitpod](https://img.shields.io/badge/gitpod-workspace-708FCC.svg?style=flat)](https://gitpod.io/#https://github.com/mkdocstrings/typescript)
39
+ [![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#typescript:gitter.im)
40
+
41
+ A Typescript handler for mkdocstrings. :warning: **Work in progress** :warning:
42
+
43
+ ## Installation
44
+
45
+ This project is available to sponsors only, through my Insiders program.
46
+ See Insiders [explanation](https://mkdocstrings.github.io/typescript/insiders/)
47
+ and [installation instructions](https://mkdocstrings.github.io/typescript/insiders/installation/).
@@ -0,0 +1,13 @@
1
+ # mkdocstrings-typescript
2
+
3
+ [![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://mkdocstrings.github.io/typescript/)
4
+ [![gitpod](https://img.shields.io/badge/gitpod-workspace-708FCC.svg?style=flat)](https://gitpod.io/#https://github.com/mkdocstrings/typescript)
5
+ [![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#typescript:gitter.im)
6
+
7
+ A Typescript handler for mkdocstrings. :warning: **Work in progress** :warning:
8
+
9
+ ## Installation
10
+
11
+ This project is available to sponsors only, through my Insiders program.
12
+ See Insiders [explanation](https://mkdocstrings.github.io/typescript/insiders/)
13
+ and [installation instructions](https://mkdocstrings.github.io/typescript/insiders/installation/).
@@ -0,0 +1,69 @@
1
+ [build-system]
2
+ requires = [
3
+ "pdm-backend",
4
+ ]
5
+ build-backend = "pdm.backend"
6
+
7
+ [project]
8
+ name = "mkdocstrings-typescript"
9
+ description = "A Typescript handler for mkdocstrings."
10
+ authors = [
11
+ { name = "Timothée Mazzucotelli", email = "dev@pawamoy.fr" },
12
+ ]
13
+ readme = "README.md"
14
+ requires-python = ">=3.8"
15
+ keywords = []
16
+ dynamic = []
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Topic :: Documentation",
30
+ "Topic :: Software Development",
31
+ "Topic :: Utilities",
32
+ "Typing :: Typed",
33
+ ]
34
+ dependencies = [
35
+ "mkdocstrings>=0.24",
36
+ "griffe-typedoc>=0.0",
37
+ ]
38
+ version = "0.0.1"
39
+
40
+ [project.license]
41
+ text = "ISC"
42
+
43
+ [project.urls]
44
+ Homepage = "https://mkdocstrings.github.io/typescript"
45
+ Documentation = "https://mkdocstrings.github.io/typescript"
46
+ Changelog = "https://mkdocstrings.github.io/typescript/changelog"
47
+ Repository = "https://github.com/mkdocstrings/typescript"
48
+ Issues = "https://github.com/mkdocstrings/typescript/issues"
49
+ Discussions = "https://github.com/mkdocstrings/typescript/discussions"
50
+ Gitter = "https://gitter.im/mkdocstrings/typescript"
51
+ Funding = "https://github.com/sponsors/pawamoy"
52
+
53
+ [tool.pdm.version]
54
+ source = "scm"
55
+
56
+ [tool.pdm.build]
57
+ package-dir = "src"
58
+ includes = [
59
+ "src/mkdocstrings_handlers",
60
+ ]
61
+ editable-backend = "editables"
62
+ source-includes = [
63
+ "share",
64
+ ]
65
+
66
+ [tool.pdm.build.wheel-data]
67
+ data = [
68
+ { path = "share/**/*", relative-to = "." },
69
+ ]
@@ -0,0 +1,5 @@
1
+ """Typescript handler for mkdocstrings."""
2
+
3
+ from mkdocstrings_handlers.typescript.handler import get_handler
4
+
5
+ __all__ = ["get_handler"]
@@ -0,0 +1,109 @@
1
+ """Debugging utilities."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import platform
7
+ import sys
8
+ from dataclasses import dataclass
9
+ from importlib import metadata
10
+
11
+
12
+ @dataclass
13
+ class Variable:
14
+ """Dataclass describing an environment variable."""
15
+
16
+ name: str
17
+ """Variable name."""
18
+ value: str
19
+ """Variable value."""
20
+
21
+
22
+ @dataclass
23
+ class Package:
24
+ """Dataclass describing a Python package."""
25
+
26
+ name: str
27
+ """Package name."""
28
+ version: str
29
+ """Package version."""
30
+
31
+
32
+ @dataclass
33
+ class Environment:
34
+ """Dataclass to store environment information."""
35
+
36
+ interpreter_name: str
37
+ """Python interpreter name."""
38
+ interpreter_version: str
39
+ """Python interpreter version."""
40
+ interpreter_path: str
41
+ """Path to Python executable."""
42
+ platform: str
43
+ """Operating System."""
44
+ packages: list[Package]
45
+ """Installed packages."""
46
+ variables: list[Variable]
47
+ """Environment variables."""
48
+
49
+
50
+ def _interpreter_name_version() -> tuple[str, str]:
51
+ if hasattr(sys, "implementation"):
52
+ impl = sys.implementation.version
53
+ version = f"{impl.major}.{impl.minor}.{impl.micro}"
54
+ kind = impl.releaselevel
55
+ if kind != "final":
56
+ version += kind[0] + str(impl.serial)
57
+ return sys.implementation.name, version
58
+ return "", "0.0.0"
59
+
60
+
61
+ def get_version(dist: str = "mkdocstrings-typescript") -> str:
62
+ """Get version of the given distribution.
63
+
64
+ Parameters:
65
+ dist: A distribution name.
66
+
67
+ Returns:
68
+ A version number.
69
+ """
70
+ try:
71
+ return metadata.version(dist)
72
+ except metadata.PackageNotFoundError:
73
+ return "0.0.0"
74
+
75
+
76
+ def get_debug_info() -> Environment:
77
+ """Get debug/environment information.
78
+
79
+ Returns:
80
+ Environment information.
81
+ """
82
+ py_name, py_version = _interpreter_name_version()
83
+ packages = ["mkdocstrings-typescript"]
84
+ variables = ["PYTHONPATH", *[var for var in os.environ if var.startswith("MKDOCSTRINGS_TYPESCRIPT")]]
85
+ return Environment(
86
+ interpreter_name=py_name,
87
+ interpreter_version=py_version,
88
+ interpreter_path=sys.executable,
89
+ platform=platform.platform(),
90
+ variables=[Variable(var, val) for var in variables if (val := os.getenv(var))],
91
+ packages=[Package(pkg, get_version(pkg)) for pkg in packages],
92
+ )
93
+
94
+
95
+ def print_debug_info() -> None:
96
+ """Print debug/environment information."""
97
+ info = get_debug_info()
98
+ print(f"- __System__: {info.platform}")
99
+ print(f"- __Python__: {info.interpreter_name} {info.interpreter_version} ({info.interpreter_path})")
100
+ print("- __Environment variables__:")
101
+ for var in info.variables:
102
+ print(f" - `{var.name}`: `{var.value}`")
103
+ print("- __Installed packages__:")
104
+ for pkg in info.packages:
105
+ print(f" - `{pkg.name}` v{pkg.version}")
106
+
107
+
108
+ if __name__ == "__main__":
109
+ print_debug_info()
@@ -0,0 +1,171 @@
1
+ """This module implements a handler for the Typescript language."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any, ClassVar, Mapping, MutableMapping
6
+
7
+ from mkdocstrings.handlers.base import BaseHandler, CollectorItem
8
+ from mkdocstrings.loggers import get_logger
9
+
10
+ if TYPE_CHECKING:
11
+ from markdown import Markdown
12
+
13
+
14
+ logger = get_logger(__name__)
15
+
16
+
17
+ class TypescriptHandler(BaseHandler):
18
+ """The Typescript handler class."""
19
+
20
+ domain: str = "typescript"
21
+ """The cross-documentation domain/language for this handler."""
22
+
23
+ enable_inventory: bool = False
24
+ """Whether this handler is interested in enabling the creation of the `objects.inv` Sphinx inventory file."""
25
+
26
+ fallback_theme = "material"
27
+ """The theme to fallback to."""
28
+
29
+ fallback_config: ClassVar[dict] = {"fallback": True}
30
+ """The configuration used to collect item during autorefs fallback."""
31
+
32
+ default_config: ClassVar[dict] = {
33
+ "base_file_path": ".",
34
+ "docstring_style": "google",
35
+ "docstring_options": {},
36
+ "show_symbol_type_heading": False,
37
+ "show_symbol_type_toc": False,
38
+ "show_root_heading": False,
39
+ "show_root_toc_entry": True,
40
+ "show_root_full_path": True,
41
+ "show_root_members_full_path": False,
42
+ "show_object_full_path": False,
43
+ "show_category_heading": False,
44
+ "show_if_no_docstring": False,
45
+ "show_signature": True,
46
+ "show_signature_annotations": False,
47
+ "signature_crossrefs": False,
48
+ "separate_signature": False,
49
+ "line_length": 60,
50
+ "merge_init_into_class": False,
51
+ "show_docstring_attributes": True,
52
+ "show_docstring_functions": True,
53
+ "show_docstring_classes": True,
54
+ "show_docstring_modules": True,
55
+ "show_docstring_description": True,
56
+ "show_docstring_examples": True,
57
+ "show_docstring_other_parameters": True,
58
+ "show_docstring_parameters": True,
59
+ "show_docstring_raises": True,
60
+ "show_docstring_receives": True,
61
+ "show_docstring_returns": True,
62
+ "show_docstring_warns": True,
63
+ "show_docstring_yields": True,
64
+ "show_source": True,
65
+ "show_bases": True,
66
+ "show_submodules": False,
67
+ "group_by_category": True,
68
+ "heading_level": 2,
69
+ "members_order": "alphabetical",
70
+ "docstring_section_style": "table",
71
+ "members": None,
72
+ "inherited_members": False,
73
+ "filters": ["!^_[^_]"],
74
+ "annotations_path": "brief",
75
+ "preload_modules": None,
76
+ "allow_inspection": True,
77
+ "summary": False,
78
+ "unwrap_annotated": False,
79
+ "parameter_headings": False,
80
+ }
81
+ """The default configuration options.
82
+
83
+ Option | Type | Description | Default
84
+ ------ | ---- | ----------- | -------
85
+ **`show_root_heading`** | `bool` | Show the heading of the object at the root of the documentation tree. | `False`
86
+ **`show_root_toc_entry`** | `bool` | If the root heading is not shown, at least add a ToC entry for it. | `True`
87
+ **`heading_level`** | `int` | The initial heading level to use. | `2`
88
+ """
89
+
90
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
91
+ """Initialize the handler.
92
+
93
+ Parameters:
94
+ *args: Passed to the [base handler][mkdocstrings.handlers.base import BaseHandler].
95
+ **kwargs: Passed to the [base handler][mkdocstrings.handlers.base import BaseHandler].
96
+ """
97
+ kwargs.pop("config_file_path", None)
98
+ super().__init__(*args, **kwargs)
99
+ self._collected: dict[str, CollectorItem] = {}
100
+
101
+ def collect(self, identifier: str, config: MutableMapping[str, Any]) -> CollectorItem: # noqa: ARG002
102
+ """Collect data given an identifier and selection configuration.
103
+
104
+ In the implementation, you typically call a subprocess that returns JSON, and load that JSON again into
105
+ a Python dictionary for example, though the implementation is completely free.
106
+
107
+ Parameters:
108
+ identifier: An identifier that was found in a markdown document for which to collect data. For example,
109
+ in Python, it would be 'mkdocstrings.handlers' to collect documentation about the handlers module.
110
+ It can be anything that you can feed to the tool of your choice.
111
+ config: All configuration options for this handler either defined globally in `mkdocs.yml` or
112
+ locally overridden in an identifier block by the user.
113
+
114
+ Returns:
115
+ Anything you want, as long as you can feed it to the `render` method.
116
+ """
117
+ return {"identifier": identifier}
118
+
119
+ def render(self, data: CollectorItem, config: Mapping[str, Any]) -> str: # noqa: ARG002
120
+ """Render a template using provided data and configuration options.
121
+
122
+ Parameters:
123
+ data: The data to render that was collected above in `collect()`.
124
+ config: All configuration options for this handler either defined globally in `mkdocs.yml` or
125
+ locally overridden in an identifier block by the user.
126
+
127
+ Returns:
128
+ The rendered template as HTML.
129
+ """
130
+ return (
131
+ f"<i><b><code>::: {data['identifier']}</code></b><br>The public version of mkdocstrings-typescript is a no-op "
132
+ "and exist only to allow building docs without errors. Please rely on docs preview in CI.</i>"
133
+ )
134
+
135
+ def update_env(self, md: Markdown, config: dict) -> None:
136
+ """Update the Jinja environment with any custom settings/filters/options for this handler.
137
+
138
+ Parameters:
139
+ md: The Markdown instance. Useful to add functions able to convert Markdown into the environment filters.
140
+ config: Configuration options for `mkdocs` and `mkdocstrings`, read from `mkdocs.yml`. See the source code
141
+ of [mkdocstrings.plugin.MkdocstringsPlugin.on_config][] to see what's in this dictionary.
142
+ """
143
+ super().update_env(md, config) # Add some mkdocstrings default filters such as highlight and convert_markdown
144
+ self.env.trim_blocks = True
145
+ self.env.lstrip_blocks = True
146
+ self.env.keep_trailing_newline = False
147
+
148
+
149
+ def get_handler(
150
+ theme: str,
151
+ custom_templates: str | None = None,
152
+ config_file_path: str | None = None,
153
+ **config: Any, # noqa: ARG001
154
+ ) -> TypescriptHandler:
155
+ """Simply return an instance of `TypescriptHandler`.
156
+
157
+ Parameters:
158
+ theme: The theme to use when rendering contents.
159
+ custom_templates: Directory containing custom templates.
160
+ config_file_path: The MkDocs configuration file path.
161
+ **config: Configuration passed to the handler.
162
+
163
+ Returns:
164
+ An instance of the handler.
165
+ """
166
+ return TypescriptHandler(
167
+ handler="typescript",
168
+ theme=theme,
169
+ custom_templates=custom_templates,
170
+ config_file_path=config_file_path,
171
+ )
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: mkdocstrings-typescript
3
- Version: 0.0.0
4
- Summary: A TypeScript handler for mkdocstrings. Available to sponsors only.
5
- Author-email: Timothée Mazzucotelli <pawamoy@pm.me>
6
- Classifier: Development Status :: 1 - Planning
7
- Requires-Python: >=3.8
8
- Description-Content-Type: text/markdown
9
-
10
- # mkdocstrings-typescript
11
-
12
- A TypeScript handler for mkdocstrings.
13
-
14
- This project is currently available to [sponsors](https://github.com/sponsors/pawamoy) only.
15
- See https://pawamoy.github.io/mkdocstrings-typescript/insiders.
@@ -1,6 +0,0 @@
1
- # mkdocstrings-typescript
2
-
3
- A TypeScript handler for mkdocstrings.
4
-
5
- This project is currently available to [sponsors](https://github.com/sponsors/pawamoy) only.
6
- See https://pawamoy.github.io/mkdocstrings-typescript/insiders.
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: mkdocstrings-typescript
3
- Version: 0.0.0
4
- Summary: A TypeScript handler for mkdocstrings. Available to sponsors only.
5
- Author-email: Timothée Mazzucotelli <pawamoy@pm.me>
6
- Classifier: Development Status :: 1 - Planning
7
- Requires-Python: >=3.8
8
- Description-Content-Type: text/markdown
9
-
10
- # mkdocstrings-typescript
11
-
12
- A TypeScript handler for mkdocstrings.
13
-
14
- This project is currently available to [sponsors](https://github.com/sponsors/pawamoy) only.
15
- See https://pawamoy.github.io/mkdocstrings-typescript/insiders.
@@ -1,6 +0,0 @@
1
- README.md
2
- pyproject.toml
3
- mkdocstrings_typescript.egg-info/PKG-INFO
4
- mkdocstrings_typescript.egg-info/SOURCES.txt
5
- mkdocstrings_typescript.egg-info/dependency_links.txt
6
- mkdocstrings_typescript.egg-info/top_level.txt
@@ -1,8 +0,0 @@
1
- [project]
2
- name = "mkdocstrings-typescript"
3
- version = "0.0.0"
4
- description = "A TypeScript handler for mkdocstrings. Available to sponsors only."
5
- authors = [{name = "Timothée Mazzucotelli", email = "pawamoy@pm.me"}]
6
- readme = "README.md"
7
- requires-python = ">=3.8"
8
- classifiers = ["Development Status :: 1 - Planning"]
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-