Skip to content

Commit

Permalink
Merge pull request #3229 from obsidian-tasks-group/code-reference
Browse files Browse the repository at this point in the history
Code reference
  • Loading branch information
claremacrae authored Dec 8, 2024
2 parents 6c3101c + 1ffacd2 commit c8820e6
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ yarn-error.log
# jest coverage files
/coverage

# Machine-generated documentation of source code
/code-docs/

# Code analysis output files
/circular-deps.png
#/circular-deps.txt
Expand Down
4 changes: 4 additions & 0 deletions contributing/Code/About Code.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This section stores information about the design and implementation of the plugi

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

## Documenting the code

- [[Generating documentation of the code]] - browse the source code interactively, and see class hierarchies.

## Comment processes

- [[How do I add a new field to the Task class]]
Expand Down
48 changes: 48 additions & 0 deletions contributing/Code/Generating documentation of the code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
publish: true
---

# Generating documentation of the code

It is now possible for developers to create a local documentation website showing the source code of the Tasks plugin.

This can help gain an understanding of the code, and see relationships between classes and functions.

## Generating the documentation

```bash
yarn code-docs
```

This runs [TypeDoc](https://typedoc.org) to populate `code-docs/index.html` and related files.

See the `typedocOptions` section in [tsconfig.json](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tsconfig.json) for options used.

## Launching the documentation

In WebStorm, use the following steps to view the generated documentation:

1. Open `code-docs/index.html`
2. Click on a browser icon to open the file in a browser of your choice.

![How to use WebStorm to open a web server showing the code documentation](webstorm-open-code-docs.png)
<span class="caption">How to use WebStorm to open a web server showing the code documentation</span>

## Using the documentation

A page like this (the Index) will open.

![Screenshot showing the code docs](code-docs-index-page.png)
<span class="caption">Screenshot showing the code docs</span>

1. Use the links on the left to browse the source code and its documentation.
2. The `Class Hierarchy` is especially useful.
3. When viewing classes and files, these Settings will be useful.
4. Click on the title to get back this Index page.

## Class Hierarchy

Here is a sample screenshot showing the class hierarchy:

![Screenshot showing the class hierarchy as of 8th December 2024|200](class-hierarchy.png)
<span class="caption">Screenshot showing the class hierarchy as of 8th December 2024</span>
Binary file added contributing/Code/class-hierarchy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contributing/Code/code-docs-index-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contributing/Code/webstorm-open-code-docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"test:dev": "jest --watch",
"deploy:local": "pwsh -ExecutionPolicy Unrestricted -NoProfile -File ./scripts/Test-TasksInLocalObsidian.ps1",
"circular-deps-text": "madge --circular --extensions ts ./src > circular-deps.txt",
"circular-deps-image": "madge --circular --extensions ts ./src --image circular-deps.png"
"circular-deps-image": "madge --circular --extensions ts ./src --image circular-deps.png",
"code-docs": "typedoc \"src/**/*\""
},
"keywords": [
"obsidian",
Expand Down Expand Up @@ -62,6 +63,8 @@
"svelte-preprocess": "^5.0.4",
"ts-jest": "^29.2.5",
"tslib": "^2.5.2",
"typedoc": "^0.27.3",
"typedoc-plugin-mdn-links": "^4.0.4",
"typescript": "^5.0.4"
},
"dependencies": {
Expand Down
15 changes: 15 additions & 0 deletions src/README-code-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- This file is embedded in the documentation generated by running 'yarn code-docs' -->

# Index

## Useful pages in this machine-generated documentation

- [Class Hierarchy](hierarchy.html)
- [Modules](modules.html)

## External pages

- [GitHub repository](https://github.com/obsidian-tasks-group/obsidian-tasks)
- [Contributing Guide](https://publish.obsidian.md/tasks-contributing/)
- [Structure of the code](https://publish.obsidian.md/tasks-contributing/Code/Structure+of+the+code)
- [User Guide](https://publish.obsidian.md/tasks/)
15 changes: 14 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,18 @@
],
"exclude": [
"node_modules/*"
]
],
"typedocOptions": {
"name": "Tasks plugin",
"readme": "src/README-code-docs.md",
"excludePrivate": false,
"excludeProtected": false,
"excludeReferences": true,
"out": "code-docs",
"gitRevision": "main",
"plugin": [
"typedoc-plugin-mdn-links"
],
"sourceLinkExternal": false
}
}
77 changes: 76 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,15 @@
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.8.tgz#21a907684723bbbaa5f0974cf7730bd797eb8e62"
integrity sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==

"@gerrit0/mini-shiki@^1.24.0":
version "1.24.1"
resolved "https://registry.yarnpkg.com/@gerrit0/mini-shiki/-/mini-shiki-1.24.1.tgz#60ef10f4e2cfac7a9223e10b88c128438aa44fd8"
integrity sha512-PNP/Gjv3VqU7z7DjRgO3F9Ok5frTKqtpV+LJW1RzMcr2zpRk0ulhEWnbcNGXzPC7BZyWMIHrkfQX2GZRfxrn6Q==
dependencies:
"@shikijs/engine-oniguruma" "^1.24.0"
"@shikijs/types" "^1.24.0"
"@shikijs/vscode-textmate" "^9.3.0"

"@humanwhocodes/config-array@^0.11.14":
version "0.11.14"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"
Expand Down Expand Up @@ -929,6 +938,27 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@shikijs/engine-oniguruma@^1.24.0":
version "1.24.0"
resolved "https://registry.yarnpkg.com/@shikijs/engine-oniguruma/-/engine-oniguruma-1.24.0.tgz#4e6f49413fbc96dabfa30cb232ca1acf5ca1a446"
integrity sha512-Eua0qNOL73Y82lGA4GF5P+G2+VXX9XnuUxkiUuwcxQPH4wom+tE39kZpBFXfUuwNYxHSkrSxpB1p4kyRW0moSg==
dependencies:
"@shikijs/types" "1.24.0"
"@shikijs/vscode-textmate" "^9.3.0"

"@shikijs/[email protected]", "@shikijs/types@^1.24.0":
version "1.24.0"
resolved "https://registry.yarnpkg.com/@shikijs/types/-/types-1.24.0.tgz#a1755b125cb8fb1780a876a0a57242939eafd79f"
integrity sha512-aptbEuq1Pk88DMlCe+FzXNnBZ17LCiLIGWAeCWhoFDzia5Q5Krx3DgnULLiouSdd6+LUM39XwXGppqYE0Ghtug==
dependencies:
"@shikijs/vscode-textmate" "^9.3.0"
"@types/hast" "^3.0.4"

"@shikijs/vscode-textmate@^9.3.0":
version "9.3.0"
resolved "https://registry.yarnpkg.com/@shikijs/vscode-textmate/-/vscode-textmate-9.3.0.tgz#b2f1776e488c1d6c2b6cd129bab62f71bbc9c7ab"
integrity sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==

"@sinclair/typebox@^0.27.8":
version "0.27.8"
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
Expand Down Expand Up @@ -1054,6 +1084,13 @@
dependencies:
"@types/node" "*"

"@types/hast@^3.0.4":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/hast/-/hast-3.0.4.tgz#1d6b39993b82cea6ad783945b0508c25903e15aa"
integrity sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==
dependencies:
"@types/unist" "*"

"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0":
version "2.0.6"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7"
Expand Down Expand Up @@ -1149,6 +1186,11 @@
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.5.tgz#cb6e2a691b70cb177c6e3ae9c1d2e8b2ea8cd304"
integrity sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==

"@types/unist@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.3.tgz#acaab0f919ce69cce629c2d4ed2eb4adc1b6c20c"
integrity sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==

"@types/yargs-parser@*":
version "21.0.3"
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15"
Expand Down Expand Up @@ -4142,6 +4184,11 @@ log-symbols@^4.1.0:
chalk "^4.1.0"
is-unicode-supported "^0.1.0"

lunr@^2.3.9:
version "2.3.9"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==

lz-string@^1.4.4:
version "1.5.0"
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.5.0.tgz#c1ab50f77887b712621201ba9fd4e3a6ed099941"
Expand Down Expand Up @@ -4206,7 +4253,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.0.7.tgz#8a1f07896d82b10926bd3744a2420009f88974a8"
integrity sha512-C0X0KQmGm3N2ftbTGBhSyuydQ+vV1LC3f3zPvT3RXHXNZrvfPZcoXp/N5DOa8vedX/rTMm2CjTtivFg2STJMRQ==

[email protected]:
[email protected], markdown-it@^14.1.0:
version "14.1.0"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45"
integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==
Expand Down Expand Up @@ -4324,6 +4371,13 @@ minimatch@^5.0.1:
dependencies:
brace-expansion "^2.0.1"

minimatch@^9.0.5:
version "9.0.5"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5"
integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
Expand Down Expand Up @@ -5664,6 +5718,22 @@ typed-array-length@^1.0.4:
for-each "^0.3.3"
is-typed-array "^1.1.9"

typedoc-plugin-mdn-links@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/typedoc-plugin-mdn-links/-/typedoc-plugin-mdn-links-4.0.4.tgz#3da2263a4d13952212a4d962a4bd8c1ee4fbb54f"
integrity sha512-rp0qiELXDso1VTFZVbLmO06SsdePD0j+h9JurxI6F8puM/euj6WZYKL5uWSWvu0r3wdUkus3KPQQEMmZ+rn5/g==

typedoc@^0.27.3:
version "0.27.3"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.27.3.tgz#0fad232181ce0ac7eda27fe78e56a4b863e1fe59"
integrity sha512-oWT7zDS5oIaxYL5yOikBX4cL99CpNAZn6mI24JZQxsYuIHbtguSSwJ7zThuzNNwSE0wqhlfTSd99HgqKu2aQXQ==
dependencies:
"@gerrit0/mini-shiki" "^1.24.0"
lunr "^2.3.9"
markdown-it "^14.1.0"
minimatch "^9.0.5"
yaml "^2.6.1"

typescript@^3.9.10, typescript@^3.9.7:
version "3.9.10"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
Expand Down Expand Up @@ -5878,6 +5948,11 @@ y18n@^5.0.5:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==

yaml@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.6.1.tgz#42f2b1ba89203f374609572d5349fb8686500773"
integrity sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==

yargs-parser@^21.0.0, yargs-parser@^21.1.1:
version "21.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
Expand Down

0 comments on commit c8820e6

Please sign in to comment.