Skip to content

Commit c8820e6

Browse files
authored
Merge pull request #3229 from obsidian-tasks-group/code-reference
Code reference
2 parents 6c3101c + 1ffacd2 commit c8820e6

File tree

10 files changed

+164
-3
lines changed

10 files changed

+164
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ yarn-error.log
2020
# jest coverage files
2121
/coverage
2222

23+
# Machine-generated documentation of source code
24+
/code-docs/
25+
2326
# Code analysis output files
2427
/circular-deps.png
2528
#/circular-deps.txt

contributing/Code/About Code.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This section stores information about the design and implementation of the plugi
66

77
- [[Structure of the code]] - the directory structure of the source code
88

9+
## Documenting the code
10+
11+
- [[Generating documentation of the code]] - browse the source code interactively, and see class hierarchies.
12+
913
## Comment processes
1014

1115
- [[How do I add a new field to the Task class]]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
publish: true
3+
---
4+
5+
# Generating documentation of the code
6+
7+
It is now possible for developers to create a local documentation website showing the source code of the Tasks plugin.
8+
9+
This can help gain an understanding of the code, and see relationships between classes and functions.
10+
11+
## Generating the documentation
12+
13+
```bash
14+
yarn code-docs
15+
```
16+
17+
This runs [TypeDoc](https://typedoc.org) to populate `code-docs/index.html` and related files.
18+
19+
See the `typedocOptions` section in [tsconfig.json](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tsconfig.json) for options used.
20+
21+
## Launching the documentation
22+
23+
In WebStorm, use the following steps to view the generated documentation:
24+
25+
1. Open `code-docs/index.html`
26+
2. Click on a browser icon to open the file in a browser of your choice.
27+
28+
![How to use WebStorm to open a web server showing the code documentation](webstorm-open-code-docs.png)
29+
<span class="caption">How to use WebStorm to open a web server showing the code documentation</span>
30+
31+
## Using the documentation
32+
33+
A page like this (the Index) will open.
34+
35+
![Screenshot showing the code docs](code-docs-index-page.png)
36+
<span class="caption">Screenshot showing the code docs</span>
37+
38+
1. Use the links on the left to browse the source code and its documentation.
39+
2. The `Class Hierarchy` is especially useful.
40+
3. When viewing classes and files, these Settings will be useful.
41+
4. Click on the title to get back this Index page.
42+
43+
## Class Hierarchy
44+
45+
Here is a sample screenshot showing the class hierarchy:
46+
47+
![Screenshot showing the class hierarchy as of 8th December 2024|200](class-hierarchy.png)
48+
<span class="caption">Screenshot showing the class hierarchy as of 8th December 2024</span>
412 KB
Loading
268 KB
Loading
470 KB
Loading

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"test:dev": "jest --watch",
1717
"deploy:local": "pwsh -ExecutionPolicy Unrestricted -NoProfile -File ./scripts/Test-TasksInLocalObsidian.ps1",
1818
"circular-deps-text": "madge --circular --extensions ts ./src > circular-deps.txt",
19-
"circular-deps-image": "madge --circular --extensions ts ./src --image circular-deps.png"
19+
"circular-deps-image": "madge --circular --extensions ts ./src --image circular-deps.png",
20+
"code-docs": "typedoc \"src/**/*\""
2021
},
2122
"keywords": [
2223
"obsidian",
@@ -62,6 +63,8 @@
6263
"svelte-preprocess": "^5.0.4",
6364
"ts-jest": "^29.2.5",
6465
"tslib": "^2.5.2",
66+
"typedoc": "^0.27.3",
67+
"typedoc-plugin-mdn-links": "^4.0.4",
6568
"typescript": "^5.0.4"
6669
},
6770
"dependencies": {

src/README-code-docs.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- This file is embedded in the documentation generated by running 'yarn code-docs' -->
2+
3+
# Index
4+
5+
## Useful pages in this machine-generated documentation
6+
7+
- [Class Hierarchy](hierarchy.html)
8+
- [Modules](modules.html)
9+
10+
## External pages
11+
12+
- [GitHub repository](https://github.com/obsidian-tasks-group/obsidian-tasks)
13+
- [Contributing Guide](https://publish.obsidian.md/tasks-contributing/)
14+
- [Structure of the code](https://publish.obsidian.md/tasks-contributing/Code/Structure+of+the+code)
15+
- [User Guide](https://publish.obsidian.md/tasks/)

tsconfig.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,18 @@
4242
],
4343
"exclude": [
4444
"node_modules/*"
45-
]
45+
],
46+
"typedocOptions": {
47+
"name": "Tasks plugin",
48+
"readme": "src/README-code-docs.md",
49+
"excludePrivate": false,
50+
"excludeProtected": false,
51+
"excludeReferences": true,
52+
"out": "code-docs",
53+
"gitRevision": "main",
54+
"plugin": [
55+
"typedoc-plugin-mdn-links"
56+
],
57+
"sourceLinkExternal": false
58+
}
4659
}

yarn.lock

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,15 @@
631631
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.8.tgz#21a907684723bbbaa5f0974cf7730bd797eb8e62"
632632
integrity sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==
633633

634+
"@gerrit0/mini-shiki@^1.24.0":
635+
version "1.24.1"
636+
resolved "https://registry.yarnpkg.com/@gerrit0/mini-shiki/-/mini-shiki-1.24.1.tgz#60ef10f4e2cfac7a9223e10b88c128438aa44fd8"
637+
integrity sha512-PNP/Gjv3VqU7z7DjRgO3F9Ok5frTKqtpV+LJW1RzMcr2zpRk0ulhEWnbcNGXzPC7BZyWMIHrkfQX2GZRfxrn6Q==
638+
dependencies:
639+
"@shikijs/engine-oniguruma" "^1.24.0"
640+
"@shikijs/types" "^1.24.0"
641+
"@shikijs/vscode-textmate" "^9.3.0"
642+
634643
"@humanwhocodes/config-array@^0.11.14":
635644
version "0.11.14"
636645
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"
@@ -929,6 +938,27 @@
929938
"@nodelib/fs.scandir" "2.1.5"
930939
fastq "^1.6.0"
931940

941+
"@shikijs/engine-oniguruma@^1.24.0":
942+
version "1.24.0"
943+
resolved "https://registry.yarnpkg.com/@shikijs/engine-oniguruma/-/engine-oniguruma-1.24.0.tgz#4e6f49413fbc96dabfa30cb232ca1acf5ca1a446"
944+
integrity sha512-Eua0qNOL73Y82lGA4GF5P+G2+VXX9XnuUxkiUuwcxQPH4wom+tE39kZpBFXfUuwNYxHSkrSxpB1p4kyRW0moSg==
945+
dependencies:
946+
"@shikijs/types" "1.24.0"
947+
"@shikijs/vscode-textmate" "^9.3.0"
948+
949+
"@shikijs/[email protected]", "@shikijs/types@^1.24.0":
950+
version "1.24.0"
951+
resolved "https://registry.yarnpkg.com/@shikijs/types/-/types-1.24.0.tgz#a1755b125cb8fb1780a876a0a57242939eafd79f"
952+
integrity sha512-aptbEuq1Pk88DMlCe+FzXNnBZ17LCiLIGWAeCWhoFDzia5Q5Krx3DgnULLiouSdd6+LUM39XwXGppqYE0Ghtug==
953+
dependencies:
954+
"@shikijs/vscode-textmate" "^9.3.0"
955+
"@types/hast" "^3.0.4"
956+
957+
"@shikijs/vscode-textmate@^9.3.0":
958+
version "9.3.0"
959+
resolved "https://registry.yarnpkg.com/@shikijs/vscode-textmate/-/vscode-textmate-9.3.0.tgz#b2f1776e488c1d6c2b6cd129bab62f71bbc9c7ab"
960+
integrity sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==
961+
932962
"@sinclair/typebox@^0.27.8":
933963
version "0.27.8"
934964
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
@@ -1054,6 +1084,13 @@
10541084
dependencies:
10551085
"@types/node" "*"
10561086

1087+
"@types/hast@^3.0.4":
1088+
version "3.0.4"
1089+
resolved "https://registry.yarnpkg.com/@types/hast/-/hast-3.0.4.tgz#1d6b39993b82cea6ad783945b0508c25903e15aa"
1090+
integrity sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==
1091+
dependencies:
1092+
"@types/unist" "*"
1093+
10571094
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0":
10581095
version "2.0.6"
10591096
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7"
@@ -1149,6 +1186,11 @@
11491186
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.5.tgz#cb6e2a691b70cb177c6e3ae9c1d2e8b2ea8cd304"
11501187
integrity sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==
11511188

1189+
"@types/unist@*":
1190+
version "3.0.3"
1191+
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.3.tgz#acaab0f919ce69cce629c2d4ed2eb4adc1b6c20c"
1192+
integrity sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==
1193+
11521194
"@types/yargs-parser@*":
11531195
version "21.0.3"
11541196
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15"
@@ -4142,6 +4184,11 @@ log-symbols@^4.1.0:
41424184
chalk "^4.1.0"
41434185
is-unicode-supported "^0.1.0"
41444186

4187+
lunr@^2.3.9:
4188+
version "2.3.9"
4189+
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
4190+
integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==
4191+
41454192
lz-string@^1.4.4:
41464193
version "1.5.0"
41474194
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.5.0.tgz#c1ab50f77887b712621201ba9fd4e3a6ed099941"
@@ -4206,7 +4253,7 @@ [email protected]:
42064253
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.0.7.tgz#8a1f07896d82b10926bd3744a2420009f88974a8"
42074254
integrity sha512-C0X0KQmGm3N2ftbTGBhSyuydQ+vV1LC3f3zPvT3RXHXNZrvfPZcoXp/N5DOa8vedX/rTMm2CjTtivFg2STJMRQ==
42084255

4209-
4256+
[email protected], markdown-it@^14.1.0:
42104257
version "14.1.0"
42114258
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45"
42124259
integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==
@@ -4324,6 +4371,13 @@ minimatch@^5.0.1:
43244371
dependencies:
43254372
brace-expansion "^2.0.1"
43264373

4374+
minimatch@^9.0.5:
4375+
version "9.0.5"
4376+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5"
4377+
integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==
4378+
dependencies:
4379+
brace-expansion "^2.0.1"
4380+
43274381
minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
43284382
version "1.2.8"
43294383
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
@@ -5664,6 +5718,22 @@ typed-array-length@^1.0.4:
56645718
for-each "^0.3.3"
56655719
is-typed-array "^1.1.9"
56665720

5721+
typedoc-plugin-mdn-links@^4.0.4:
5722+
version "4.0.4"
5723+
resolved "https://registry.yarnpkg.com/typedoc-plugin-mdn-links/-/typedoc-plugin-mdn-links-4.0.4.tgz#3da2263a4d13952212a4d962a4bd8c1ee4fbb54f"
5724+
integrity sha512-rp0qiELXDso1VTFZVbLmO06SsdePD0j+h9JurxI6F8puM/euj6WZYKL5uWSWvu0r3wdUkus3KPQQEMmZ+rn5/g==
5725+
5726+
typedoc@^0.27.3:
5727+
version "0.27.3"
5728+
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.27.3.tgz#0fad232181ce0ac7eda27fe78e56a4b863e1fe59"
5729+
integrity sha512-oWT7zDS5oIaxYL5yOikBX4cL99CpNAZn6mI24JZQxsYuIHbtguSSwJ7zThuzNNwSE0wqhlfTSd99HgqKu2aQXQ==
5730+
dependencies:
5731+
"@gerrit0/mini-shiki" "^1.24.0"
5732+
lunr "^2.3.9"
5733+
markdown-it "^14.1.0"
5734+
minimatch "^9.0.5"
5735+
yaml "^2.6.1"
5736+
56675737
typescript@^3.9.10, typescript@^3.9.7:
56685738
version "3.9.10"
56695739
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
@@ -5878,6 +5948,11 @@ y18n@^5.0.5:
58785948
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
58795949
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
58805950

5951+
yaml@^2.6.1:
5952+
version "2.6.1"
5953+
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.6.1.tgz#42f2b1ba89203f374609572d5349fb8686500773"
5954+
integrity sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==
5955+
58815956
yargs-parser@^21.0.0, yargs-parser@^21.1.1:
58825957
version "21.1.1"
58835958
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"

0 commit comments

Comments
 (0)