mkdocstrings-matlab 0.7.0__tar.gz → 0.8.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.github/workflows/qualify.yaml +9 -3
  2. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.github/workflows/release.yaml +2 -2
  3. mkdocstrings_matlab-0.8.0/.github/workflows/update-templates.yaml +48 -0
  4. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.gitignore +1 -0
  5. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/CHANGELOG.md +8 -0
  6. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/PKG-INFO +4 -4
  7. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/api.md +0 -4
  8. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/configuration/headings.md +21 -10
  9. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/configuration/members.md +0 -5
  10. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/index.md +0 -7
  11. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/mkdocs.yml +4 -8
  12. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/pyproject.toml +6 -12
  13. mkdocstrings_matlab-0.8.0/scripts/copy_and_update_python_templates.py +121 -0
  14. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/src/mkdocstrings_handlers/matlab/handler.py +29 -7
  15. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/src/mkdocstrings_handlers/matlab/models.py +33 -3
  16. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/children.html.jinja +172 -0
  17. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/docstring/namespaces.html.jinja +86 -0
  18. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/docstring/properties.html.jinja +109 -0
  19. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/folder.html.jinja +121 -0
  20. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/namespace.html.jinja +121 -0
  21. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/property.html.jinja +120 -0
  22. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/style.css +26 -0
  23. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/summary/namespaces.html.jinja +21 -0
  24. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/summary/properties.html.jinja +21 -0
  25. mkdocstrings_matlab-0.8.0/src/mkdocstrings_handlers/matlab/templates/material/summary.html.jinja +26 -0
  26. mkdocstrings_matlab-0.7.0/src/mkdocs_material_matlab/__init__.py +0 -4
  27. mkdocstrings_matlab-0.7.0/src/mkdocs_material_matlab/css/style.css +0 -7
  28. mkdocstrings_matlab-0.7.0/src/mkdocs_material_matlab/mkdocs_material_matlab.py +0 -20
  29. mkdocstrings_matlab-0.7.0/uv.lock +0 -2015
  30. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.github/CODEOWNERS +0 -0
  31. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.github/workflows/docs.yaml +0 -0
  32. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.python-version +0 -0
  33. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.vscode/launch.json +0 -0
  34. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/.vscode/settings.json +0 -0
  35. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/LICENSE +0 -0
  36. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/README.md +0 -0
  37. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/changelog.md +0 -0
  38. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/credits.md +0 -0
  39. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/debug.py +0 -0
  40. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/img/preview_dark.png +0 -0
  41. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/img/preview_light.png +0 -0
  42. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/index.md +0 -0
  43. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/license.md +0 -0
  44. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/logo.png +0 -0
  45. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/logo.svg +0 -0
  46. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/overrides/main.html +0 -0
  47. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/overrides/partials/toc-item.html +0 -0
  48. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+module/+submodule/Contents.m +0 -0
  49. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+module/+submodule/subfunction.m +0 -0
  50. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+module/aClass.m +0 -0
  51. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+module/do_something.m +0 -0
  52. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+module/module.md +0 -0
  53. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+module/readme.md +0 -0
  54. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mymembers/BaseClass.m +0 -0
  55. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mymembers/Contents.m +0 -0
  56. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mymembers/ThisClass.m +0 -0
  57. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mymembers/mymembers.md +0 -0
  58. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mymembers/this_function.m +0 -0
  59. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mynamespace/classA.m +0 -0
  60. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mynamespace/classB.m +0 -0
  61. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mynamespace/mynamespace.md +0 -0
  62. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mynamespace/readme.md +0 -0
  63. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+mynamespace/typed_function.m +0 -0
  64. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+undocumented/ClassWithoutDocstring.m +0 -0
  65. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+undocumented/function_with_docstring.m +0 -0
  66. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+undocumented/function_without_docstring.m +0 -0
  67. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/+undocumented/undocumented.md +0 -0
  68. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/Class.m +0 -0
  69. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/OtherClass.m +0 -0
  70. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/Thing.m +0 -0
  71. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/do_output.m +0 -0
  72. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/do_something.m +0 -0
  73. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/do_varargin.m +0 -0
  74. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/myClass.m +0 -0
  75. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/myParent.m +0 -0
  76. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/myfunction.m +0 -0
  77. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/snippets/print_hello.m +0 -0
  78. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/stylesheets/extra.css +0 -0
  79. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/configuration/docstrings.md +0 -0
  80. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/configuration/general.md +0 -0
  81. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/configuration/signatures.md +0 -0
  82. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/docstrings/google.md +0 -0
  83. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/docstrings/numpy.md +0 -0
  84. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/docs/usage/docstrings/sphinx.md +0 -0
  85. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/logo.svg +0 -0
  86. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/renovate.json +0 -0
  87. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/requirements.lock +0 -0
  88. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/src/mkdocstrings_handlers/matlab/__init__.py +0 -0
  89. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/src/mkdocstrings_handlers/matlab/collect.py +0 -0
  90. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/src/mkdocstrings_handlers/matlab/enums.py +0 -0
  91. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/src/mkdocstrings_handlers/matlab/py.typed +0 -0
  92. {mkdocstrings_matlab-0.7.0 → mkdocstrings_matlab-0.8.0}/src/mkdocstrings_handlers/matlab/treesitter.py +0 -0
@@ -10,6 +10,7 @@ on:
10
10
  - synchronize
11
11
  - labeled
12
12
  - unlabeled
13
+ - edited
13
14
  branches:
14
15
  - main
15
16
 
@@ -38,11 +39,16 @@ jobs:
38
39
  uses: actions/checkout@v4
39
40
  with:
40
41
  fetch-depth: 0
41
- ref: ${{ github.sha }}
42
+ ref: main
42
43
 
43
- - name: Force correct release branch on workflow sha
44
+ - name: Create fake commit with PR title
44
45
  run: |
45
- git checkout -B ${{ github.ref_name }} ${{ github.sha }}
46
+ git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
47
+ git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
48
+ git switch -c temp-${{ github.run_id }}
49
+ touch temp.txt
50
+ git add temp.txt
51
+ git commit -m "${{ github.event.pull_request.title }}"
46
52
 
47
53
  - name: Install the latest version of uv
48
54
  uses: astral-sh/setup-uv@v5
@@ -55,7 +55,7 @@ jobs:
55
55
 
56
56
  - name: Update version and changelogs
57
57
  id: semantic-release
58
- uses: python-semantic-release/python-semantic-release@v9.16.0
58
+ uses: python-semantic-release/python-semantic-release@v9.16.1
59
59
  with:
60
60
  build: false
61
61
  changelog: true
@@ -81,7 +81,7 @@ jobs:
81
81
  - name: Publish package distributions to GitHub Releases
82
82
  if: steps.semantic-release.outputs.released == 'true'
83
83
  id: publish-dist
84
- uses: python-semantic-release/publish-action@v9.16.0
84
+ uses: python-semantic-release/publish-action@v9.16.1
85
85
  with:
86
86
  github_token: ${{ steps.app-token.outputs.token }}
87
87
  tag: ${{ steps.semantic-release.outputs.tag }}
@@ -0,0 +1,48 @@
1
+ name: Update template copies
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - synchronize
8
+ - reopened
9
+ - edited
10
+
11
+ permissions:
12
+ contents: write
13
+
14
+ jobs:
15
+ update-templates:
16
+ runs-on: ubuntu-latest
17
+ if: contains(github.event.pull_request.title, 'mkdocstrings-python')
18
+
19
+ steps:
20
+
21
+ - name: Checkout repository
22
+ uses: actions/checkout@v4
23
+ with:
24
+ fetch-depth: 0
25
+ ref: ${{ github.sha }}
26
+
27
+ - name: Force correct release branch on workflow sha
28
+ run: |
29
+ git checkout -B ${{ github.ref_name }} ${{ github.sha }}
30
+
31
+ - name: Install the latest version of uv
32
+ uses: astral-sh/setup-uv@v5
33
+ with:
34
+ version: "latest"
35
+
36
+ - name: Run script
37
+ run: |
38
+ uv sync
39
+ uv run python scripts/copy_and_update_python_templates.py
40
+
41
+ - name: Commit changes
42
+ continue-on-error: true # Ignore if there are no changes
43
+ run: |
44
+ git config --global user.name 'github-actions[bot]'
45
+ git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
46
+ git add .
47
+ git commit -m "Update templates"
48
+ git push origin ${{ github.ref_name }}
@@ -122,6 +122,7 @@ celerybeat.pid
122
122
  *.sage.py
123
123
 
124
124
  # Environments
125
+ uv.lock
125
126
  .env
126
127
  .venv
127
128
  env/
@@ -1,6 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v0.8.0 (2025-01-13)
5
+
6
+ ### Features
7
+
8
+ - Update dependencies ([#46](https://github.com/watermarkhu/mkdocstrings-matlab/pull/46),
9
+ [`03229a2`](https://github.com/watermarkhu/mkdocstrings-matlab/commit/03229a2e7ef8ee46dc680b676a796ae38c6617b7))
10
+
11
+
4
12
  ## v0.7.0 (2025-01-12)
5
13
 
6
14
  ### Chores
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocstrings-matlab
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: A MATLAB handler for mkdocstrings
5
5
  Author-email: Mark Hu <watermarkhu@gmail.com>
6
6
  License: MIT
@@ -21,11 +21,11 @@ Classifier: Topic :: Software Development :: Documentation
21
21
  Classifier: Topic :: Utilities
22
22
  Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.10
24
- Requires-Dist: charset-normalizer>=3.3.2
24
+ Requires-Dist: charset-normalizer==3.4.1
25
25
  Requires-Dist: mkdocstrings-python==1.13.0
26
26
  Requires-Dist: mkdocstrings==0.27.0
27
- Requires-Dist: tree-sitter-matlab>=1.0.2
28
- Requires-Dist: tree-sitter>=0.23.2
27
+ Requires-Dist: tree-sitter-matlab==1.0.3
28
+ Requires-Dist: tree-sitter==0.23.2
29
29
  Description-Content-Type: text/markdown
30
30
 
31
31
  <!-- --8<-- [start:header] -->
@@ -1,8 +1,4 @@
1
1
 
2
- !!! note
3
-
4
- Due to that for the documentation of mkdocstrings-matlab both the MATLAB and the Python handler are loaded, the symbols shown for Python objects will be incorrect (see [Configuration](usage/index.md#configuration)).
5
-
6
2
  ::: mkdocstrings_handlers.matlab
7
3
  handler: python
8
4
  options:
@@ -553,13 +553,17 @@ plugins:
553
553
  === "With symbol type in headings"
554
554
 
555
555
  ```markdown
556
- ::: +mynamespace
556
+ ::: docs/snippets
557
557
  options:
558
+ members:
559
+ - mynamespace
558
560
  show_symbol_type_heading: true
559
561
  ```
560
562
 
561
- ::: +mynamespace
563
+ ::: docs/snippets
562
564
  options:
565
+ members:
566
+ - mynamespace
563
567
  show_symbol_type_heading: true
564
568
  show_docstring_input_arguments: false
565
569
  show_docstring_output_arguments: false
@@ -567,13 +571,17 @@ plugins:
567
571
  === "Without symbol type in headings"
568
572
 
569
573
  ```markdown
570
- ::: +mynamespace
574
+ ::: docs/snippets
571
575
  options:
576
+ members:
577
+ - mynamespace
572
578
  show_symbol_type_heading: false
573
579
  ```
574
580
 
575
- ::: +mynamespace
581
+ ::: docs/snippets
576
582
  options:
583
+ members:
584
+ - mynamespace
577
585
  show_symbol_type_heading: false
578
586
  show_docstring_input_arguments: false
579
587
  show_docstring_output_arguments: false
@@ -586,11 +594,12 @@ plugins:
586
594
  Show the symbol type in the Table of Contents.
587
595
 
588
596
  This option will prefix items in the ToC with
589
- <code class="doc-symbol doc-symbol-attribute"></code>,
597
+ <code class="doc-symbol doc-symbol-property"></code>,
590
598
  <code class="doc-symbol doc-symbol-function"></code>,
591
599
  <code class="doc-symbol doc-symbol-method"></code>,
592
- <code class="doc-symbol doc-symbol-class"></code> or
593
- <code class="doc-symbol doc-symbol-module"></code> types.
600
+ <code class="doc-symbol doc-symbol-class"></code>,
601
+ <code class="doc-symbol doc-symbol-namespace"></code> or.
602
+ <code class="doc-symbol doc-symbol-folder"></code> types.
594
603
  See also [`show_symbol_type_heading`][show_symbol_type_heading].
595
604
 
596
605
  ```yaml title="in mkdocs.yml (global configuration)"
@@ -603,7 +612,7 @@ plugins:
603
612
  show_symbol_type_toc: true
604
613
  ```
605
614
 
606
- 1. :warning: When using material theme, make sure to also enable the plugin `mkdocs-material-matlab` such that the right heading types are displayed. Otherwise, <code class="doc-symbol doc-symbol-attribute"></code> will be shown as `attr` and <code class="doc-symbol doc-symbol-module"></code> will be shown as `mod`, as the mkdocstrings-matlab plugin is reusing assets from mkdocstrings-python.
615
+ 1. :warning: When using material theme, make sure to also enable the plugin `mkdocs-material-matlab` such that the right heading types are displayed.
607
616
 
608
617
 
609
618
  ```md title="or in docs/some_page.md (local configuration)"
@@ -617,12 +626,13 @@ plugins:
617
626
  === "With symbol type in ToC"
618
627
 
619
628
  <ul style="list-style: none;">
620
- <li><code class="doc-symbol doc-symbol-module"></code> namespace</li>
629
+ <li><code class="doc-symbol doc-symbol-folder"></code> folder</li>
630
+ <li><code class="doc-symbol doc-symbol-namespace"></code> namespace</li>
621
631
  <li><code class="doc-symbol doc-symbol-function"></code> function</li>
622
632
  <li><code class="doc-symbol doc-symbol-class"></code> Class
623
633
  <ul style="list-style: none;">
624
634
  <li><code class="doc-symbol doc-symbol-method"></code> method</li>
625
- <li><code class="doc-symbol doc-symbol-attribute"></code> property</li>
635
+ <li><code class="doc-symbol doc-symbol-property"></code> property</li>
626
636
  </ul>
627
637
  </li>
628
638
  </ul>
@@ -630,6 +640,7 @@ plugins:
630
640
  === "Without symbol type in ToC"
631
641
 
632
642
  <ul style="list-style: none;">
643
+ <li>folder</li>
633
644
  <li>namespace</li>
634
645
  <li>function</li>
635
646
  <li>Class
@@ -700,11 +700,6 @@ plugins:
700
700
  summary:
701
701
  functions: true
702
702
 
703
- !!! warning
704
-
705
- In the summary, the title of the properties summary will be *attributes*, and the title of the namespaces summary will be *modules*. This is due to mkdocstrings-matlab's dependency on mkdocstrings-python. For now, mkdocstrings-matlab does not implement its own Jinja templates for rendering, leading to these summary titles.
706
-
707
-
708
703
  ## `show_labels`
709
704
 
710
705
  - **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }**
@@ -27,21 +27,14 @@ plugins:
27
27
  ... # the MATLAB handler configuration
28
28
  ```
29
29
 
30
- When using the [material](https://squidfunk.github.io/mkdocs-material) theme, it is best to also configure the `mkdocs_material_matlab` plugin. This additional plugin, which is installed together with mkdocstrings-matlab, will overrule the symbols shown with [`show_symbol_type_heading`][] and [`show_symbol_type_toc`][] to show the correct symbols as per MATLAB nomenclature.
31
-
32
30
  ```yaml title="mkdocs.yml"
33
31
  plugins:
34
- - mkdocs_material_matlab
35
32
  - mkdocstrings:
36
33
  default_handler: matlab
37
34
  matlab:
38
35
  ... # the MATLAB handler configuration
39
36
  ```
40
37
 
41
- ??? warning "I want to document both MATLAB and Python"
42
-
43
- The `mkdocs_material_matlab` plugin will also change the symbols for the Python handler. This means that Python modules will not be tagged with symbol `mod` but `name` (namespace), and attributes are not tagged with symbol `attr` but `prop` (property).
44
-
45
38
  ## Injecting documentation
46
39
 
47
40
  With the MATLAB handler installed and configured as default handler, you can inject documentation for a module, class, function, or any other MATLAB object with *mkdocstrings*' [autodoc syntax], in your Markdown pages:
@@ -127,11 +127,10 @@ markdown_extensions:
127
127
  toc_depth: 3
128
128
 
129
129
  plugins:
130
+ - callouts
130
131
  - autorefs
131
132
  - search
132
133
  - markdown-exec
133
- - callouts
134
- - mkdocs-material-matlab
135
134
  - mkdocstrings:
136
135
  default_handler: matlab
137
136
  handlers:
@@ -201,16 +200,13 @@ plugins:
201
200
  summary: true
202
201
  unwrap_annotated: true
203
202
 
203
+ - minify:
204
+ minify_html: !ENV [DEPLOY, false]
205
+
204
206
  - git-revision-date-localized:
205
207
  enabled: !ENV [DEPLOY, false]
206
208
  enable_creation_date: true
207
209
  type: timeago
208
- - minify:
209
- minify_html: !ENV [DEPLOY, false]
210
- - group:
211
- enabled: !ENV [MATERIAL_INSIDERS, false]
212
- plugins:
213
- - typeset
214
210
 
215
211
  extra:
216
212
  version:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mkdocstrings-matlab"
3
- version = "0.7.0"
3
+ version = "0.8.0"
4
4
  description = "A MATLAB handler for mkdocstrings"
5
5
  authors = [
6
6
  { name = "Mark Hu", email = "watermarkhu@gmail.com" }
@@ -10,10 +10,10 @@ readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  dependencies = [
12
12
  "mkdocstrings==0.27.0",
13
- "mkdocstrings-python==1.13.0", # Later versions will currently break
14
- "charset-normalizer>=3.3.2",
15
- "tree-sitter>=0.23.2",
16
- "tree-sitter-matlab>=1.0.2",
13
+ "mkdocstrings-python==1.13.0",
14
+ "charset-normalizer==3.4.1",
15
+ "tree-sitter==0.23.2",
16
+ "tree-sitter-matlab==1.0.3",
17
17
  ]
18
18
  classifiers = [
19
19
  "Development Status :: 4 - Beta",
@@ -44,19 +44,13 @@ managed = true
44
44
  allow-direct-references = true
45
45
 
46
46
  [tool.hatch.build.targets.wheel]
47
- packages = ["src/mkdocstrings_handlers", "src/mkdocs_material_matlab"]
48
-
49
- [project.entry-points."mkdocs.plugins"]
50
- mkdocs-material-matlab = "mkdocs_material_matlab:MkdocsMaterialMatlabPlugin"
47
+ packages = ["src/mkdocstrings_handlers"]
51
48
 
52
49
  [dependency-groups]
53
50
  docs = [
54
51
  "mkdocs-material>=9.5.33",
55
52
  "markdown-exec>=1.10.0",
56
53
  "mkdocs-callouts>=1.15.0",
57
- "mkdocs-with-pdf>=0.9.3",
58
- "mkdocs-gen-files>=0.5.0",
59
- "mkdocs-literate-nav>=0.6.1",
60
54
  "mkdocs-git-revision-date-localized-plugin>=1.3.0",
61
55
  "mkdocs-minify-plugin>=0.8.0",
62
56
  "mike>=2.1.3",
@@ -0,0 +1,121 @@
1
+ """A script to copy the modules and attributes templates from
2
+ the python handler to the matlab handler and update the names"""
3
+
4
+ from mkdocstrings_handlers.python.handler import PythonHandler
5
+ from pathlib import Path
6
+ import re
7
+
8
+ # Get the templates directory of the python handler
9
+ pythonHandler = PythonHandler("python", "material")
10
+ templatesDir = pythonHandler.get_templates_dir()
11
+ targetDir = (
12
+ Path(__file__).parent.parent
13
+ / "src"
14
+ / "mkdocstrings_handlers"
15
+ / "matlab"
16
+ / "templates"
17
+ )
18
+
19
+
20
+ def copy_template(
21
+ sourcePath: str,
22
+ targetPath: str,
23
+ mapping: dict[str, str] = {},
24
+ theme: str = "material",
25
+ ):
26
+ sourceFile = templatesDir / theme / sourcePath
27
+ targetFile = targetDir / theme / targetPath
28
+ content = sourceFile.read_text()
29
+ pattern = re.compile(
30
+ "|".join([re.escape(k) for k in sorted(mapping, key=len, reverse=True)]),
31
+ flags=re.DOTALL,
32
+ )
33
+ content = pattern.sub(lambda x: mapping[x.group(0)], content)
34
+ targetFile.write_text(content)
35
+
36
+ return (targetFile, content)
37
+
38
+
39
+ # Copy the namespace and module templates
40
+ copy_template(
41
+ "_base/module.html.jinja",
42
+ "folder.html.jinja",
43
+ {"doc-symbol-module": "doc-symbol-folder"},
44
+ )
45
+ copy_template(
46
+ "_base/module.html.jinja",
47
+ "namespace.html.jinja",
48
+ {"doc-symbol-module": "doc-symbol-namespace"},
49
+ )
50
+
51
+ # Copy the property template
52
+ copy_template(
53
+ "_base/attribute.html.jinja",
54
+ "property.html.jinja",
55
+ {"doc-symbol-attribute": "doc-symbol-property"},
56
+ )
57
+
58
+ # Copy the summary modules template
59
+ copy_template(
60
+ "_base/summary.html.jinja",
61
+ "summary.html.jinja",
62
+ {
63
+ "summary/modules": "summary/namespaces",
64
+ "summary/attributes": "summary/properties",
65
+ },
66
+ )
67
+
68
+
69
+ ## Copy the summary properties template
70
+ copy_template(
71
+ "_base/summary/attributes.html.jinja",
72
+ "summary/properties.html.jinja",
73
+ {
74
+ "docstring/attributes": "docstring/properties",
75
+ "Summary of attributes": "Summary of properties",
76
+ },
77
+ )
78
+ copy_template(
79
+ "_base/docstring/attributes.html.jinja",
80
+ "docstring/properties.html.jinja",
81
+ {
82
+ 'lang.t("Attributes:")': '"Properties:"',
83
+ 'lang.t("ATTRIBUTE")': '"PROPERTY:"',
84
+ " attributes ": " properties ",
85
+ '"Attributes"': '"Properties"',
86
+ },
87
+ )
88
+
89
+ ## Copy the summary namespaces template
90
+ copy_template(
91
+ "_base/summary/modules.html.jinja",
92
+ "summary/namespaces.html.jinja",
93
+ {
94
+ "docstring/modules": "docstring/namespaces",
95
+ "Summary of modules": "Summary of namespaces",
96
+ },
97
+ )
98
+ copy_template(
99
+ "_base/docstring/modules.html.jinja",
100
+ "docstring/namespaces.html.jinja",
101
+ {
102
+ 'lang.t("Modules:")': '"Namespaces:"',
103
+ 'lang.t("MODULE")': '"NAMESPACE:"',
104
+ " modules ": " namespaces ",
105
+ '"Modules"': '"Namespaces"',
106
+ },
107
+ )
108
+
109
+ ## Copy children template
110
+ copy_template(
111
+ "_base/children.html.jinja",
112
+ "children.html.jinja",
113
+ {
114
+ "-attributes": "-properties",
115
+ "Attributes": "Properties",
116
+ "-modules": "-namespaces",
117
+ "Modules": "Modules",
118
+ "{% if config.show_submodules %}": "{% if config.show_submodules or obj.is_folder %}",
119
+ "{% elif child.is_module and config.show_submodules %}": "{% elif (child.is_namespace and config.show_submodules) or obj.is_folder %}",
120
+ },
121
+ )
@@ -2,8 +2,9 @@
2
2
 
3
3
  from pathlib import Path
4
4
  from collections import ChainMap
5
+ from jinja2.loaders import FileSystemLoader
5
6
  from markdown import Markdown
6
- from mkdocstrings.extension import PluginError
7
+ from mkdocs.exceptions import PluginError
7
8
  from mkdocstrings.handlers.base import BaseHandler, CollectorItem, CollectionError
8
9
  from mkdocstrings_handlers.python import rendering
9
10
  from typing import Any, ClassVar, Mapping
@@ -152,7 +153,9 @@ class MatlabHandler(BaseHandler):
152
153
 
153
154
  def __init__(
154
155
  self,
155
- *args: Any,
156
+ handler: str,
157
+ theme: str,
158
+ custom_templates: str | None = None,
156
159
  config_file_path: str | None = None,
157
160
  paths: list[str] | None = None,
158
161
  paths_recursive: bool = False,
@@ -163,7 +166,9 @@ class MatlabHandler(BaseHandler):
163
166
  Initialize the handler with the given configuration.
164
167
 
165
168
  Args:
166
- *args (Any): Variable length argument list.
169
+ handler: The name of the handler.
170
+ theme: The name of theme to use.
171
+ custom_templates: Directory containing custom templates.
167
172
  config_file_path (str | None, optional): Path to the configuration file. Defaults to None.
168
173
  paths (list[str] | None, optional): List of paths to include. Defaults to None.
169
174
  paths_recursive (bool, optional): Whether to include paths recursively. Defaults to False.
@@ -173,7 +178,16 @@ class MatlabHandler(BaseHandler):
173
178
  Returns:
174
179
  None
175
180
  """
176
- super().__init__(*args, **kwargs)
181
+
182
+ super().__init__(handler, theme, custom_templates=custom_templates)
183
+
184
+ theme_path = Path(__file__).resolve().parent / "templates" / theme
185
+ if theme_path.exists() and isinstance(self.env.loader, FileSystemLoader):
186
+ # Insert our templates directory at the beginning of the search path to overload the Python templates
187
+ self.env.loader.searchpath.insert(0, str(theme_path))
188
+ css_path = theme_path / "style.css"
189
+ if css_path.exists():
190
+ self.extra_css += "\n" + css_path.read_text(encoding="utf-8")
177
191
 
178
192
  if paths is None or config_file_path is None:
179
193
  config_path = None
@@ -182,13 +196,19 @@ class MatlabHandler(BaseHandler):
182
196
  config_path = Path(config_file_path).parent
183
197
  full_paths = [(config_path / path).resolve() for path in paths]
184
198
 
199
+ if pathIds := [str(path) for path in full_paths if not path.is_dir()]:
200
+ raise PluginError(
201
+ "The following paths do not exist or are not directories: "
202
+ + ", ".join(pathIds)
203
+ )
204
+
185
205
  self.paths: PathCollection = PathCollection(
186
206
  full_paths, recursive=paths_recursive, config_path=config_path
187
207
  )
188
208
  self.lines: LinesCollection = self.paths.lines_collection
189
209
  self._locale: str = locale
190
210
 
191
- def get_templates_dir(self, handler: str | None = None) -> Path:
211
+ def get_templates_dir(self, *args, **kwargs) -> Path:
192
212
  # use the python handler templates
193
213
  # (it assumes the python handler is installed)
194
214
  return super().get_templates_dir("python")
@@ -254,7 +274,6 @@ class MatlabHandler(BaseHandler):
254
274
  }
255
275
 
256
276
  # Map docstring options
257
- final_config["show_submodules"] = config.get("show_subnamespaces", False)
258
277
  final_config["show_docstring_attributes"] = config.get(
259
278
  "show_docstring_properties", True
260
279
  )
@@ -339,7 +358,10 @@ class MatlabHandler(BaseHandler):
339
358
  raise CollectionError("Empty identifier")
340
359
 
341
360
  final_config = ChainMap(config, self.default_config) # type: ignore[arg-type]
342
- return self.paths.resolve(identifier, config=final_config)
361
+ model = self.paths.resolve(identifier, config=final_config)
362
+ if model is None:
363
+ raise CollectionError(f"Identifier '{identifier}' not found")
364
+ return model
343
365
 
344
366
 
345
367
  def get_handler(
@@ -141,13 +141,24 @@ class MatlabObject(Object):
141
141
  path_collection (PathCollection | None): The collection of paths related to the object.
142
142
  **kwargs: Arbitrary keyword arguments.
143
143
  """
144
-
145
144
  self.path_collection: "PathCollection | None" = path_collection
146
145
  lines_collection = (
147
146
  path_collection.lines_collection if path_collection is not None else None
148
147
  )
149
148
  super().__init__(*args, lines_collection=lines_collection, **kwargs)
150
149
 
150
+ @property
151
+ def namespaces(self) -> dict[str, "Namespace"]:
152
+ return {}
153
+
154
+ @property
155
+ def is_namespace(self) -> bool:
156
+ return False
157
+
158
+ @property
159
+ def is_folder(self) -> bool:
160
+ return False
161
+
151
162
  @property
152
163
  def canonical_path(self) -> str:
153
164
  """
@@ -426,6 +437,8 @@ class Property(MatlabMixin, Attribute, MatlabObject):
426
437
  self.SetAccess: AccessEnum = SetAccess
427
438
  self.getter: Function | None = None
428
439
 
440
+ self.extra["mkdocstrings"] = {"template": "property.html.jinja"}
441
+
429
442
  @property
430
443
  def Private(self) -> bool:
431
444
  private = self.Access != AccessEnum.public
@@ -554,10 +567,22 @@ class Folder(MatlabMixin, PathMixin, Module, MatlabObject):
554
567
 
555
568
  def __init__(self, *args: Any, **kwargs: Any) -> None:
556
569
  super().__init__(*args, **kwargs)
557
- self.labels = {"Folder"}
570
+ self.extra["mkdocstrings"] = {"template": "folder.html.jinja"}
558
571
 
559
572
  def __repr__(self) -> str:
560
- return f"Folder({self.path!r})"
573
+ return f"Folder({self.filepath!r})"
574
+
575
+ @property
576
+ def namespaces(self) -> dict[str, "Namespace"]:
577
+ return {
578
+ name: member
579
+ for name, member in self.members.items()
580
+ if isinstance(member, Namespace)
581
+ }
582
+
583
+ @property
584
+ def is_folder(self) -> bool:
585
+ return True
561
586
 
562
587
 
563
588
  class Namespace(MatlabMixin, PathMixin, Module, MatlabObject):
@@ -574,6 +599,7 @@ class Namespace(MatlabMixin, PathMixin, Module, MatlabObject):
574
599
  def __init__(self, *args: Any, **kwargs: Any) -> None:
575
600
  super().__init__(*args, **kwargs)
576
601
  self._access: AccessEnum = AccessEnum.public
602
+ self.extra["mkdocstrings"] = {"template": "namespace.html.jinja"}
577
603
 
578
604
  def __repr__(self) -> str:
579
605
  return f"Namespace({self.path!r})"
@@ -585,3 +611,7 @@ class Namespace(MatlabMixin, PathMixin, Module, MatlabObject):
585
611
  if self.filepath
586
612
  else False
587
613
  )
614
+
615
+ @property
616
+ def is_namespace(self) -> bool:
617
+ return True