Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit c719db0

Browse files
committed
feat(docs): document writing documentation
1 parent 7877830 commit c719db0

5 files changed

Lines changed: 108 additions & 40 deletions

File tree

docs/Developer Guide/!!!meta.json

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,10 +2018,10 @@
20182018
},
20192019
{
20202020
"isClone": false,
2021-
"noteId": "LjqM0VUL1CrU",
2021+
"noteId": "Sow7ThJozkzJ",
20222022
"notePath": [
20232023
"jdjRLhLV3TtI",
2024-
"LjqM0VUL1CrU"
2024+
"Sow7ThJozkzJ"
20252025
],
20262026
"title": "Documentation",
20272027
"notePosition": 90,
@@ -2032,26 +2032,35 @@
20322032
"attributes": [],
20332033
"format": "markdown",
20342034
"dataFileName": "Documentation.md",
2035-
"attachments": [],
2035+
"attachments": [
2036+
{
2037+
"attachmentId": "2bUrJyt2yfsd",
2038+
"title": "image.png",
2039+
"role": "image",
2040+
"mime": "image/png",
2041+
"position": 10,
2042+
"dataFileName": "Documentation_image.png"
2043+
}
2044+
],
20362045
"dirFileName": "Documentation",
20372046
"children": [
20382047
{
20392048
"isClone": false,
2040-
"noteId": "HptkyArOlRI5",
2049+
"noteId": "LjqM0VUL1CrU",
20412050
"notePath": [
20422051
"jdjRLhLV3TtI",
2043-
"LjqM0VUL1CrU",
2044-
"HptkyArOlRI5"
2052+
"Sow7ThJozkzJ",
2053+
"LjqM0VUL1CrU"
20452054
],
2046-
"title": "User-facing documentation",
2055+
"title": "Documentation references in the application",
20472056
"notePosition": 10,
20482057
"prefix": null,
20492058
"isExpanded": false,
20502059
"type": "text",
20512060
"mime": "text/html",
20522061
"attributes": [],
20532062
"format": "markdown",
2054-
"dataFileName": "User-facing documentation.md",
2063+
"dataFileName": "Documentation references in th.md",
20552064
"attachments": []
20562065
}
20572066
]
@@ -2064,7 +2073,7 @@
20642073
"dtKC3FmoWOrv"
20652074
],
20662075
"title": "Testing",
2067-
"notePosition": 100,
2076+
"notePosition": 110,
20682077
"prefix": null,
20692078
"isExpanded": false,
20702079
"type": "text",
@@ -2183,7 +2192,7 @@
21832192
"dHfw0XZE515z"
21842193
],
21852194
"title": "Sub-projects",
2186-
"notePosition": 110,
2195+
"notePosition": 120,
21872196
"prefix": null,
21882197
"isExpanded": false,
21892198
"type": "text",
@@ -2486,7 +2495,7 @@
24862495
"ibAPHul7Efvr"
24872496
],
24882497
"title": "Notes for old development",
2489-
"notePosition": 120,
2498+
"notePosition": 130,
24902499
"prefix": null,
24912500
"isExpanded": false,
24922501
"type": "text",
@@ -2551,7 +2560,7 @@
25512560
"QRLbiDXNxoWN"
25522561
],
25532562
"title": "Troubleshooting",
2554-
"notePosition": 130,
2563+
"notePosition": 140,
25552564
"prefix": null,
25562565
"isExpanded": false,
25572566
"type": "text",
@@ -2590,7 +2599,7 @@
25902599
"x6lgrdztQwVB"
25912600
],
25922601
"title": "Installation",
2593-
"notePosition": 140,
2602+
"notePosition": 150,
25942603
"prefix": null,
25952604
"isExpanded": false,
25962605
"type": "text",
Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,73 @@
11
# Documentation
2-
## Hard-coded links
2+
<figure class="image image-style-align-right"><img style="aspect-ratio:205/162;" src="Documentation_image.png" width="205" height="162"></figure>
33

4-
Hard-coded links are present throughout the application, either in dialogs or in the source code as comments.
4+
There are multiple types of documentation for Trilium:
55

6-
You can identify these links by searching for:
6+
* The _User Guide_ represents the user-facing documentation. This documentation can be browsed by users directly from within Trilium, by pressing <kbd>F1</kbd>.
7+
* The _Developer's Guide_ represents a set of Markdown documents that present the internals of Trilium, for developers.
8+
* _Release Notes_, this contains the change log for each released or soon-to-be-released version. The release notes are used automatically by the CI when releasing a version.
9+
* The _Script API_, which is an automatically generated documentation for the front-end and back-end APIs for scripts.
710

8-
```
9-
https://triliumnext.github.io/Docs/Wiki/
10-
```
11+
## Editing documentation
1112

12-
## Help buttons
13+
There are two ways to modify documentation:
1314

14-
There is a pattern of “?” buttons throughout the application which make use of the `data-help-page` attribute. Whenever these buttons are pressed, the user is redirected to the corresponding wiki page by prepending the wiki root URL to the `data-help-page` attribute.
15+
* Using a special mode of Trilium.
16+
* By manually editing the files.
1517

16-
Since the current wiki has a different structure than the original, for example to link to [https://github.com/TriliumNext/Docs/blob/main/Wiki/tree-concepts.md](https://github.com/TriliumNext/Docs/blob/main/Wiki/tree-concepts.md) the `data-help-page` attribute must be set to `tree-concepts.md`.
18+
### Using `docs:edit`
1719

18-
For links to headings, simply add the heading after the `.md`: `tree-concepts.md#prefix`
20+
To edit the documentation using Trilium, set up a working development environment and run the following commands:
1921

20-
You can identify those by looking for:
22+
* On most operating systems, `npm run electron:switch` followed by `npm run docs:edit`
23+
* On NixOS, `npm run docs:edit-nix`.
2124

22-
* `.attr("data-help-page"`
23-
* `data-help-page="`
25+
> [!NOTE]
26+
> `npm run docs:edit` acts very similar to `npm run electron:start` in the sense that you cannot both be editing documentation and starting a server. Using both `npm run electron:start` and `docs:edit` is possible, since they are using the same Electron instance.
27+
28+
How it works:
29+
30+
* At startup, the documentation from `docs/` is imported from Markdown into a in-memory session (the initialization of the database is already handled by the application).
31+
* Each modification will trigger after 10s an export from the in-memory Trilium session back to Markdown, including the meta file.
32+
33+
### Manual editing
34+
35+
Apart from the User Guide, it's generally feasible to make small modifications directly using a Markdown editor or VS Code, for example.
36+
37+
When making manual modifications, avoid:
38+
39+
* Uploading pictures, since images are handled as Trilium attachments which are stored in the meta file.
40+
* Changing the file or directory structure in any way, since that is also handled by the meta file. A missing file will most certainly cause a crash at start-up when attempting to edit the docs using Trilium.
41+
42+
### Reviewing & committing the changes
43+
44+
Since the documentation is tracked with Git, after making the manual or automatic modifications (wait at least 10s after making the modification) the changes will reflect in Git.
45+
46+
Make sure to analyze each modified file and report possible issues.
47+
48+
Important aspects to consider:
49+
50+
* The Trilium import/export mechanism is not perfect, so if you make some modifications to the documentation using `docs:edit`, at the next import/export/import cycle some whitespace might get thrown in. It's generally safe to commit the changes as-is.
51+
* Since we are importing Markdown, editing HTML and then exporting the HTML back to Markdown there might be some edge cases where the formatting is not properly preserved. Try to identify such cases and report them in order to get them fixed (this will benefit also the users).
52+
53+
## Location of the documentation
54+
55+
All documentation is stored in the [Notes](https://github.com/TriliumNext/Notes) repository:
56+
57+
* `docs/Developer Guide` contains Markdown documentation that can be modified either externally (using a Markdown editor, or internally using Trilium).
58+
* `docs/Release Notes` is also stored in Markdown format and can be freely edited.
59+
* `docs/Script API` contains auto-generated files and thus must not be modified.
60+
* `docs/User Guide` contains also Markdown-only documentation but must generally not be edited externally.
61+
* The reason is that the `docs:edit` feature will not only import/export this documentation, but also generate the corresponding HTML documentation and meta structure in `src/public/app/doc_notes/en/User Guide`.
62+
* It's theoretically possible to edit the Markdown files externally and then run `docs:edit` and trigger a change in order to build the documentation, but that would not be a very productive workflow.
63+
64+
## Updating the Script API
65+
66+
As mentioned previously, the Script API is not manually editable since it is auto-generated using TypeDoc.
67+
68+
To update the API documentation, simply run `npm run docs:build`. Compare the changes (if any) and commit them.
69+
70+
Note that in order to simulate the environment a script would have, some fake source files (in the sense that they are only used for documentation) are being used as entrypoints for the documentation:
71+
72+
* For back-end scripts, the script is located in `src/services/backend_script_entrypoint.ts`.
73+
* For front-end scripts, the script is located in `src/public/app/services/frontend_script_entrypoint.ts`.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Documentation references in the application
2+
## Hard-coded links
3+
4+
Hard-coded links are present throughout the application, either in dialogs or in the source code as comments.
5+
6+
You can identify these links by searching for:
7+
8+
```
9+
https://triliumnext.github.io/Docs/Wiki/
10+
```
11+
12+
## Help buttons
13+
14+
There is a pattern of “?” buttons throughout the application which make use of the `data-help-page` attribute. Whenever these buttons are pressed, the user is redirected to the corresponding wiki page by prepending the wiki root URL to the `data-help-page` attribute.
15+
16+
Since the current wiki has a different structure than the original, for example to link to [https://github.com/TriliumNext/Docs/blob/main/Wiki/tree-concepts.md](https://github.com/TriliumNext/Docs/blob/main/Wiki/tree-concepts.md) the `data-help-page` attribute must be set to `tree-concepts.md`.
17+
18+
For links to headings, simply add the heading after the `.md`: `tree-concepts.md#prefix`
19+
20+
You can identify those by looking for:
21+
22+
* `.attr("data-help-page"`
23+
* `data-help-page="`

docs/Developer Guide/Developer Guide/Documentation/User-facing documentation.md

Lines changed: 0 additions & 14 deletions
This file was deleted.
7.15 KB
Loading

0 commit comments

Comments
 (0)