t-doc-common 0.3.dev1__tar.gz → 0.4__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.
Files changed (54) hide show
  1. t_doc_common-0.4/.github/workflows/publish.yml +19 -0
  2. t_doc_common-0.4/.hgtags +3 -0
  3. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/PKG-INFO +8 -5
  4. t_doc_common-0.4/README.md +11 -0
  5. t_doc_common-0.4/docs/conf.py +18 -0
  6. t_doc_common-0.4/docs/development.md +96 -0
  7. t_doc_common-0.4/docs/edit.md +106 -0
  8. t_doc_common-0.4/docs/index.md +15 -0
  9. t_doc_common-0.4/docs/install.md +121 -0
  10. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/pyproject.toml +2 -1
  11. t_doc_common-0.4/serve.bat +5 -0
  12. t_doc_common-0.4/serve.desktop +13 -0
  13. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/__init__.py +3 -1
  14. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/cli.py +68 -12
  15. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/defaults.py +9 -2
  16. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/static/styles/t-doc.css +4 -0
  17. t_doc_common-0.3.dev1/.hgtags +0 -1
  18. t_doc_common-0.3.dev1/README.md +0 -9
  19. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/.github/workflows/deploy-github-pages.yml +0 -0
  20. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/.gitignore +0 -0
  21. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/.gitmodules +0 -0
  22. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/.hgignore +0 -0
  23. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/.hgsub +0 -0
  24. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/.hgsubstate +0 -0
  25. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/LICENSE.txt +0 -0
  26. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/.gitignore +0 -0
  27. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/.prettierrc +0 -0
  28. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/README.md +0 -0
  29. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/bin/index.js +0 -0
  30. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/demo/index.html +0 -0
  31. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/demo/main-thread.js +0 -0
  32. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/demo/module-workers-polyfill.min.js +0 -0
  33. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/demo/script.js +0 -0
  34. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/demo/worker.js +0 -0
  35. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/demo/wrapped-worker.js +0 -0
  36. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/index.d.ts +0 -0
  37. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/index.mjs +0 -0
  38. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/package-lock.json +0 -0
  39. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/package.json +0 -0
  40. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-bundler-friendly.mjs +0 -0
  41. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-node.mjs +0 -0
  42. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-opfs-async-proxy.js +0 -0
  43. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-worker1-bundler-friendly.mjs +0 -0
  44. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-worker1-promiser.js +0 -0
  45. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-worker1-promiser.mjs +0 -0
  46. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-worker1.js +0 -0
  47. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3.js +0 -0
  48. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3.mjs +0 -0
  49. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/ext/sqlite-wasm/sqlite-wasm/jswasm/sqlite3.wasm +0 -0
  50. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/common.mk +0 -0
  51. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/components/copyright.html +0 -0
  52. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/static/tdoc-sql.js +0 -0
  53. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/theme.toml +0 -0
  54. {t_doc_common-0.3.dev1 → t_doc_common-0.4}/tdoc/common/util.py +0 -0
@@ -0,0 +1,19 @@
1
+ # Copyright 2024 Caroline Blank <caro@c-space.org>
2
+ # Copyright 2024 Remy Blank <remy@c-space.org>
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ name: Publish
6
+ on:
7
+ push:
8
+ branches: [main]
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+ pages: write
14
+ id-token: write
15
+
16
+ jobs:
17
+ deploy:
18
+ uses: t-doc-org/common/.github/workflows/deploy-github-pages.yml@main
19
+ secrets: inherit
@@ -0,0 +1,3 @@
1
+ 267a6c8ad66dde08f2b75d2d82d0d2985ca8f137 0.2
2
+ ea2973414a3779c7ffbed73279ab8d811c795268 0.3
3
+ dcb01efb897d0e04063b92998c17b02b587761c7 0.4
@@ -1,8 +1,9 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: t-doc-common
3
- Version: 0.3.dev1
3
+ Version: 0.4
4
4
  Summary: Common functionality for t-doc
5
5
  Project-URL: Code, https://github.com/t-docs/common
6
+ Project-URL: Documentation, https://t-doc.org/common/
6
7
  Project-URL: Homepage, https://t-doc.org/
7
8
  Author-email: Remy Blank <remy@c-space.org>, Caroline Blank <caro@c-space.org>
8
9
  License: Copyright 2024 Caroline Blank <caro@c-space.org>
@@ -45,15 +46,17 @@ Requires-Dist: sphinx-design>=0.6.0
45
46
  Requires-Dist: sphinx-exercise>=0.4.1
46
47
  Requires-Dist: sphinx-proof>=0.1.3
47
48
  Requires-Dist: sphinx-togglebutton>=0.3.2
48
- Requires-Dist: sphinx<8,>=7.4.7
49
+ Requires-Dist: sphinx>=8.0.2
49
50
  Description-Content-Type: text/markdown
50
51
 
51
52
  <!-- Copyright 2024 Caroline Blank <caro@c-space.org> -->
52
53
  <!-- Copyright 2024 Remy Blank <remy@c-space.org> -->
53
54
  <!-- SPDX-License-Identifier: MIT -->
54
55
 
55
- # t-doc - Base commune
56
+ # t-doc - Common
56
57
 
57
- Ce package contient la fonctionnalité commune aux documents basés sur t-doc.
58
+ [![Publish](https://github.com/t-doc-org/common/actions/workflows/publish.yml/badge.svg)](https://github.com/t-doc-org/common/actions/workflows/publish.yml)
58
59
 
59
- Ce logiciel est distribué sous la licence [MIT](LICENSE.txt).
60
+ This package contains the common functionality for documents based on t-doc.
61
+
62
+ This software is distributed under the [MIT](LICENSE.txt) license.
@@ -0,0 +1,11 @@
1
+ <!-- Copyright 2024 Caroline Blank <caro@c-space.org> -->
2
+ <!-- Copyright 2024 Remy Blank <remy@c-space.org> -->
3
+ <!-- SPDX-License-Identifier: MIT -->
4
+
5
+ # t-doc - Common
6
+
7
+ [![Publish](https://github.com/t-doc-org/common/actions/workflows/publish.yml/badge.svg)](https://github.com/t-doc-org/common/actions/workflows/publish.yml)
8
+
9
+ This package contains the common functionality for documents based on t-doc.
10
+
11
+ This software is distributed under the [MIT](LICENSE.txt) license.
@@ -0,0 +1,18 @@
1
+ # Copyright 2024 Caroline Blank <caro@c-space.org>
2
+ # Copyright 2024 Remy Blank <remy@c-space.org>
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ import time
6
+
7
+ from tdoc.common.defaults import *
8
+
9
+ project = "t-doc"
10
+ copyright = f"{time.strftime('%Y')} Remy Blank"
11
+ license = 'MIT'
12
+ language = 'en'
13
+
14
+ keep_warnings = True
15
+
16
+ html_theme_options = {
17
+ 'repository_url': 'https://github.com/t-doc-org/common',
18
+ }
@@ -0,0 +1,96 @@
1
+ <!-- Copyright 2024 Caroline Blank <caro@c-space.org> -->
2
+ <!-- Copyright 2024 Remy Blank <remy@c-space.org> -->
3
+ <!-- SPDX-License-Identifier: MIT -->
4
+
5
+ # Development
6
+
7
+ This page describes how to set up t-doc for development. It isn't necessary for
8
+ creating and editing documents.
9
+
10
+ ## Install
11
+
12
+ - Install the [required packages](install.md#requirements) for your system.
13
+
14
+ - Clone the `t-doc/common` repository (substitute `USER` with your username).
15
+
16
+ ```{code-block} shell-session
17
+ hg clone https://USER@c-space.net/rc/hg/t-doc/common
18
+ cd common
19
+ ```
20
+
21
+ - Enable git subrepositories.
22
+
23
+ ```{code-block} shell-session
24
+ echo -e '[subrepos]\ngit:allowed = true\n' >> .hg/hgrc
25
+ ```
26
+
27
+ - Checkout the subrepositories and activate the `main` bookmark.
28
+
29
+ ```{code-block} shell-session
30
+ hg checkout main
31
+ ```
32
+
33
+ - Install the `t-doc-common` package from editable sources.
34
+
35
+ `````{tab-set}
36
+ :sync-group: platform
37
+ ````{tab-item} Windows
38
+ :sync: windows
39
+ ```{code-block} shell-session
40
+ python -m pip install --editable .
41
+ ```
42
+ ````
43
+ ````{tab-item} macOS
44
+ :sync: macos
45
+ ```{code-block} shell-session
46
+ python -m pip install --user --editable .
47
+ ```
48
+ You may have to add `$HOME/.local/bin` to your `PATH`.
49
+ ````
50
+ ````{tab-item} Linux
51
+ :sync: linux
52
+ ```{code-block} shell-session
53
+ python -m pip install --user --editable .
54
+ ```
55
+ You may have to add `$HOME/.local/bin` to your `PATH`.
56
+ ````
57
+ `````
58
+
59
+ ## Upgrade
60
+
61
+ - Pull missing changesets from the `t-doc/common` repository.
62
+
63
+ ```{code-block} shell-session
64
+ cd common
65
+ hg pull
66
+ ```
67
+
68
+ - Update to the branch head.
69
+
70
+ ```{code-block} shell-session
71
+ hg update --check
72
+ ```
73
+
74
+ - Upgrade the `t-doc-common` package metadata and any out-of-date dependencies.
75
+
76
+ `````{tab-set}
77
+ :sync-group: platform
78
+ ````{tab-item} Windows
79
+ :sync: windows
80
+ ```{code-block} shell-session
81
+ python -m pip install --upgrade --editable .
82
+ ```
83
+ ````
84
+ ````{tab-item} macOS
85
+ :sync: macos
86
+ ```{code-block} shell-session
87
+ python -m pip install --user --upgrade --editable .
88
+ ```
89
+ ````
90
+ ````{tab-item} Linux
91
+ :sync: linux
92
+ ```{code-block} shell-session
93
+ python -m pip install --user --upgrade --editable .
94
+ ```
95
+ ````
96
+ `````
@@ -0,0 +1,106 @@
1
+ <!-- Copyright 2024 Caroline Blank <caro@c-space.org> -->
2
+ <!-- Copyright 2024 Remy Blank <remy@c-space.org> -->
3
+ <!-- SPDX-License-Identifier: MIT -->
4
+
5
+ # Create & edit documents
6
+
7
+ ## Check out a repository
8
+
9
+ Documents are grouped into **repositories**, which represent the unit of
10
+ deployment. Each document repository is tracked as a Mercurial repository. A
11
+ repository can be checked out with (substitute `USER` with your username, and
12
+ `REPO` with the name of the repository):
13
+
14
+ ```{code-block} shell-session
15
+ hg checkout https://USER@c-space.net/rc/hg/t-doc/REPO
16
+ ```
17
+
18
+ The typical structure of a document repository is shown below. The source files
19
+ are located below the `docs` directory.
20
+
21
+ ```{code-block}
22
+ :class: line-height-normal
23
+ ├── .github
24
+ │ └── workflows
25
+ │ └── publish.yml A workflow to publish the repository
26
+ ├── docs
27
+ │ ├── conf.py The Sphinx configuration
28
+ │ ├── index.md The main index page
29
+ │ └── ... The source documents
30
+ ├── .gitignore
31
+ ├── .hgignore
32
+ ├── LICENSE.txt
33
+ ├── README.md
34
+ ├── serve.bat A script to run the local server on Windows
35
+ └── serve.desktop A desktop entry to run the local server on Linux
36
+ ```
37
+
38
+ ## Edit documents
39
+
40
+ - **Run the local server.**
41
+
42
+ `````{tab-set}
43
+ :sync-group: platform
44
+ ````{tab-item} Windows
45
+ :sync: windows
46
+ Double-click the file `serve.bat` in the repository directory.
47
+ ````
48
+ ````{tab-item} macOS
49
+ :sync: macos
50
+ Open a terminal, change to the repository directory, and run:
51
+ ```{code-block} shell-session
52
+ tdoc serve
53
+ ```
54
+ ````
55
+ ````{tab-item} Linux
56
+ :sync: linux
57
+ Double-click the file `serve.desktop` in the repository directory.
58
+
59
+ Alternatively, open a terminal, change to the repository directory, and run:
60
+ ```{code-block} shell-session
61
+ tdoc serve
62
+ ```
63
+ ````
64
+ `````
65
+
66
+ The server renders the source files into HTML, and serves the result over
67
+ HTTP.
68
+
69
+ ```{code-block} text
70
+ Running Sphinx v8.0.2
71
+ loading translations [fr]... done
72
+ making output directory... done
73
+ (...)
74
+ build succeeded.
75
+
76
+ The HTML pages are in _build\serve-1724331687766143000\html.
77
+ Serving at <http://[::1]:8000/>
78
+ ```
79
+
80
+ - **Navigate** to [http://localhost:8000/](http://localhost:8000/) to view the
81
+ generated pages.
82
+
83
+ - **Create and edit documents** in the `docs` directory. This can be done with
84
+ any plain text editor. The local server watches the source files and
85
+ **automatically rebulids the HTML when a file changes**. Reload the page in
86
+ the browser to view the updated output. If a build fails, the errors can be
87
+ found in the terminal.
88
+
89
+ - **Stop the local server** with {kbd}`Ctrl+C` in the terminal, or by closing
90
+ the terminal window.
91
+
92
+ - Don't forget to **commit changes frequently**.
93
+
94
+ ## Deploy documents
95
+
96
+ To deploy the repository to `tdoc.org`, make sure that all changes have been
97
+ committed (and that new files have been added with Mercurial), then push the
98
+ changes to the server.
99
+
100
+ ```{code-block} shell-session
101
+ hg push
102
+ ```
103
+
104
+ The changes should be live at `https://t-doc.org/REPO` within a few minutes. If
105
+ the build fails, GitHub will send you an email notification. It contains a link
106
+ to the build log, which should allow figuring out what went wrong.
@@ -0,0 +1,15 @@
1
+ <!-- Copyright 2024 Caroline Blank <caro@c-space.org> -->
2
+ <!-- Copyright 2024 Remy Blank <remy@c-space.org> -->
3
+ <!-- SPDX-License-Identifier: MIT -->
4
+
5
+ # t-doc
6
+
7
+ This documentation describes how to install and use t-doc.
8
+
9
+ ```{toctree}
10
+ :maxdepth: 1
11
+
12
+ install
13
+ edit
14
+ development
15
+ ```
@@ -0,0 +1,121 @@
1
+ <!-- Copyright 2024 Caroline Blank <caro@c-space.org> -->
2
+ <!-- Copyright 2024 Remy Blank <remy@c-space.org> -->
3
+ <!-- SPDX-License-Identifier: MIT -->
4
+
5
+ # Install & upgrade
6
+
7
+ ## Requirements
8
+
9
+ t-doc requires the following software to be installed:
10
+
11
+ - [Python](https://www.python.org/) 3.12 or later
12
+ - [Graphviz](https://graphviz.org/), for `{graphviz}` directives
13
+ - [Mercurial](https://www.mercurial-scm.org/), for managing source files
14
+
15
+ ### Windows
16
+
17
+ - Install [Python](https://www.python.org/).
18
+
19
+ ```{code-block} shell-session
20
+ winget install --id Python.Python.3.12
21
+ ```
22
+
23
+ - Install [Graphviz](https://graphviz.org/). The installer must be run
24
+ interactively and the **"Add Graphviz to the system PATH for all users"**
25
+ option must be enabled.
26
+
27
+ ```{code-block} shell-session
28
+ winget install --id Graphviz.Graphviz --interactive
29
+ ```
30
+
31
+ - Install [TortoiseHg](https://tortoisehg.bitbucket.io/).
32
+
33
+ ```{code-block} shell-session
34
+ winget install --id TortoiseHg.TortoiseHg
35
+ ```
36
+
37
+ - Open the TortoiseHg settings, go to your user's global settings, then click
38
+ "Edit file" and add the following to the configuration (substitute `FIRST`
39
+ and `LAST` with your first and last name, and `EMAIL` with your email
40
+ address, e.g. `Joe Smith <joe@example.com>`):
41
+
42
+ ```ini
43
+ [ui]
44
+ username = FIRST LAST <EMAIL>
45
+ ```
46
+
47
+ - (Optional, Windows 10) Install
48
+ [Windows Terminal](https://github.com/microsoft/terminal) (it's already
49
+ installed on Windows 11 and later).
50
+
51
+ ```{code-block} shell-session
52
+ winget install --id Microsoft.WindowsTerminal
53
+ ```
54
+
55
+ ### macOS
56
+
57
+ - Install [Python](https://www.python.org/), [Graphviz](https://graphviz.org/)
58
+ and [Mercurial](https://www.mercurial-scm.org/) either by hand or through a
59
+ package manager like [Homebrew](https://brew.sh/).
60
+
61
+ ### Linux
62
+
63
+ - Install [Python](https://www.python.org/), [Graphviz](https://graphviz.org/)
64
+ and [Mercurial](https://www.mercurial-scm.org/) through your system's package
65
+ manager.
66
+
67
+ ## Install
68
+
69
+ - Install the [required packages](#requirements).
70
+
71
+ - Install the `t-doc-common` package.
72
+
73
+ `````{tab-set}
74
+ :sync-group: platform
75
+ ````{tab-item} Windows
76
+ :sync: windows
77
+ ```{code-block} shell-session
78
+ python -m pip install t-doc-common
79
+ ```
80
+ ````
81
+ ````{tab-item} macOS
82
+ :sync: macos
83
+ ```{code-block} shell-session
84
+ python -m pip install --user t-doc-common
85
+ ```
86
+ You may have to add `$HOME/.local/bin` to your `PATH`.
87
+ ````
88
+ ````{tab-item} Linux
89
+ :sync: linux
90
+ ```{code-block} shell-session
91
+ python -m pip install --user t-doc-common
92
+ ```
93
+ You may have to add `$HOME/.local/bin` to your `PATH`.
94
+ ````
95
+ `````
96
+
97
+ ## Upgrade
98
+
99
+ - Upgrade the `t-doc-common` package and any out-of-date dependencies.
100
+
101
+ `````{tab-set}
102
+ :sync-group: platform
103
+ ````{tab-item} Windows
104
+ :sync: windows
105
+ ```{code-block} shell-session
106
+ python -m pip install --upgrade t-doc-common
107
+ ```
108
+ ````
109
+ ````{tab-item} macOS
110
+ :sync: macos
111
+ ```{code-block} shell-session
112
+ python -m pip install --user --upgrade t-doc-common
113
+ ```
114
+ ````
115
+ ````{tab-item} Linux
116
+ :sync: linux
117
+ ```{code-block} shell-session
118
+ python -m pip install --user --upgrade t-doc-common
119
+ ```
120
+ ````
121
+ `````
@@ -10,6 +10,7 @@ authors = [
10
10
  {name = "Caroline Blank", email = "caro@c-space.org"},
11
11
  ]
12
12
  urls.Code = "https://github.com/t-docs/common"
13
+ urls.Documentation = "https://t-doc.org/common/"
13
14
  urls.Homepage = "https://t-doc.org/"
14
15
  readme = "README.md"
15
16
  license.file = "LICENSE.txt"
@@ -28,7 +29,7 @@ requires-python = ">=3.12"
28
29
  dependencies = [
29
30
  "colorama>=0.4.6; sys_platform == 'win32'",
30
31
  "myst-parser>=3.0.1",
31
- "Sphinx>=7.4.7,<8",
32
+ "Sphinx>=8.0.2",
32
33
  "sphinx-book-theme>=1.1.3",
33
34
  "sphinx-copybutton>=0.5.2",
34
35
  "sphinx_design>=0.6.0",
@@ -0,0 +1,5 @@
1
+ @echo off
2
+ rem Copyright 2024 Caroline Blank <caro@c-space.org>
3
+ rem Copyright 2024 Remy Blank <remy@c-space.org>
4
+ rem SPDX-License-Identifier: CC-BY-NC-SA-4.0
5
+ tdoc serve
@@ -0,0 +1,13 @@
1
+ # Copyright 2024 Caroline Blank <caro@c-space.org>
2
+ # Copyright 2024 Remy Blank <remy@c-space.org>
3
+ # SPDX-License-Identifier: CC-BY-NC-SA-4.0
4
+ [Desktop Entry]
5
+ Name=Serve
6
+ Type=Application
7
+ GenericName=Start a local server
8
+ Comment=
9
+ Icon=document-preview
10
+ Exec=cd "$(dirname "%k")" && "${HOME}/.local/bin/tdoc" serve
11
+ Path=
12
+ Terminal=true
13
+ StartupNotify=false
@@ -8,7 +8,8 @@ from docutils import nodes
8
8
  from sphinx.directives.code import CodeBlock
9
9
  from sphinx.util import logging
10
10
 
11
- __version__ = '0.3.dev1'
11
+ __project__ = 't-doc-common'
12
+ __version__ = '0.4'
12
13
 
13
14
  _common = pathlib.Path(__file__).absolute().parent
14
15
  _root = _common.parent.parent
@@ -23,6 +24,7 @@ _license_urls = {
23
24
  'CC-BY-NC-4.0': 'https://creativecommons.org/licenses/by-nc/4.0/',
24
25
  'CC-BY-NC-SA-4.0': 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
25
26
  'CC-BY-ND-4.0': 'https://creativecommons.org/licenses/by-nd/4.0/',
27
+ 'MIT': 'https://opensource.org/license/mit',
26
28
  }
27
29
 
28
30
  def setup(app):
@@ -6,14 +6,18 @@ import argparse
6
6
  import contextlib
7
7
  from http import server
8
8
  import itertools
9
+ from importlib import metadata
10
+ import json
9
11
  import pathlib
10
12
  import shutil
11
13
  import socket
12
14
  import stat
13
15
  import subprocess
16
+ import sys
14
17
  import threading
15
18
  import time
16
19
 
20
+ from .. import common
17
21
  from . import util
18
22
 
19
23
 
@@ -81,6 +85,10 @@ def main(argv, stdin, stdout, stderr):
81
85
  arg('--watch', metavar='PATH', action='append', dest='watch', default=[],
82
86
  help="Additional directories to watch for changes.")
83
87
 
88
+ p = subparsers.add_parser('version', add_help=False,
89
+ help="Display version information.")
90
+ p.set_defaults(handler=cmd_version)
91
+
84
92
  cfg = parser.parse_args(argv[1:])
85
93
  cfg.stdin, cfg.stdout, cfg.stderr = stdin, stdout, stderr
86
94
  cfg.ansi = util.ansi if cfg.color else util.no_ansi
@@ -95,15 +103,6 @@ def cmd_build(cfg):
95
103
  if res.returncode != 0: return res.returncode
96
104
 
97
105
 
98
- def sphinx_build(cfg, target, *, build, **kwargs):
99
- argv = [cfg.sphinx_build, '-M', target, cfg.source, build,
100
- '--jobs=auto', '--fail-on-warning']
101
- if cfg.debug: argv += ['--show-traceback']
102
- argv += cfg.sphinx_opts
103
- return subprocess.run(argv, stdin=cfg.stdin, stdout=cfg.stdout,
104
- stderr=cfg.stderr, **kwargs)
105
-
106
-
107
106
  def cmd_clean(cfg):
108
107
  return sphinx_build(cfg, 'clean', build=cfg.build).returncode
109
108
 
@@ -129,15 +128,30 @@ def cmd_serve(cfg):
129
128
  cfg.stderr.write("Interrupted, exiting\n")
130
129
 
131
130
 
132
- class ServerBase(server.ThreadingHTTPServer):
131
+ def cmd_version(cfg):
132
+ cfg.stdout.write(f"{common.__project__}-{common.__version__}\n")
133
133
 
134
+
135
+ def sphinx_build(cfg, target, *, build, **kwargs):
136
+ argv = [cfg.sphinx_build, '-M', target, cfg.source, build,
137
+ '--jobs=auto', '--fail-on-warning']
138
+ if cfg.debug: argv += ['--show-traceback']
139
+ argv += cfg.sphinx_opts
140
+ return subprocess.run(argv, stdin=cfg.stdin, stdout=cfg.stdout,
141
+ stderr=cfg.stderr, **kwargs)
142
+
143
+
144
+ class ServerBase(server.ThreadingHTTPServer):
134
145
  def __init__(self, *args, cfg, **kwargs):
135
146
  self.cfg = cfg
136
147
  self.lock = threading.Lock()
137
- self.directory = self.cfg.build / 'html'
148
+ self.directory = self.build_dir(0) / 'html'
149
+ self.upgrade_msg = None
138
150
  self.stop = False
139
151
  self.builder = threading.Thread(target=self.watch_and_build)
140
152
  self.builder.start()
153
+ self.checker = threading.Thread(target=self.check_upgrade, daemon=True)
154
+ self.checker.start()
141
155
  super().__init__(*args, **kwargs)
142
156
 
143
157
  def server_bind(self):
@@ -227,10 +241,28 @@ class ServerBase(server.ThreadingHTTPServer):
227
241
  if ':' in host: host = f'[{host}]'
228
242
  self.cfg.stdout.write(self.cfg.ansi("Serving at <@{LBLUE}%s@{NORM}>\n")
229
243
  % f"http://{host}:{port}/")
244
+ with self.lock:
245
+ msg = self.upgrade_msg
246
+ if msg: self.cfg.stdout.write(msg)
247
+
248
+ def check_upgrade(self):
249
+ try:
250
+ project = common.__project__
251
+ upgrades, editable = pip_check_upgrades(self.cfg, project)
252
+ if project not in upgrades: return
253
+ msg = self.cfg.ansi(
254
+ "@{LYELLOW}A t-doc upgrade is available:@{NORM} "
255
+ "%s @{CYAN}%s@{NORM} => @{CYAN}%s@{NORM}\n"
256
+ "See <@{LBLUE}https://t-doc.org/common/%s#upgrade@{NORM}>\n"
257
+ % (project, metadata.version(project), upgrades[project],
258
+ 'development' if editable else 'install'))
259
+ with self.lock:
260
+ self.upgrade_msg = msg
261
+ except Exception:
262
+ if self.cfg.debug: raise
230
263
 
231
264
 
232
265
  class HandlerBase(server.SimpleHTTPRequestHandler):
233
-
234
266
  def log_request(self, code='-', size='-'):
235
267
  pass
236
268
 
@@ -240,5 +272,29 @@ class HandlerBase(server.SimpleHTTPRequestHandler):
240
272
  (format % args).translate(self._control_char_table)))
241
273
 
242
274
 
275
+ class Namespace(dict):
276
+ def __getattr__(self, name):
277
+ return self[name]
278
+
279
+
280
+ def pip(cfg, *args, json_output=False):
281
+ p = subprocess.run((sys.executable, '-m', 'pip') + args,
282
+ stdin=subprocess.DEVNULL, capture_output=True, text=True)
283
+ if p.returncode != 0: raise Exception(p.stderr)
284
+ if not json_output: return p.stdout
285
+ return json.loads(p.stdout, object_pairs_hook=Namespace)
286
+
287
+
288
+ def pip_check_upgrades(cfg, package):
289
+ data = pip(cfg, 'install', '--dry-run', '--upgrade',
290
+ '--upgrade-strategy=only-if-needed', '--only-binary=:all:',
291
+ '--report=-', '--quiet', package, json_output=True)
292
+ upgrades = {pkg.metadata.name: pkg.metadata.version for pkg in data.install}
293
+ if package not in upgrades: return {}, False
294
+ pkgs = pip(cfg, 'list', '--editable', '--format=json', json_output=True)
295
+ editable = any(pkg.name == package for pkg in pkgs)
296
+ return upgrades, editable
297
+
298
+
243
299
  if __name__ == '__main__':
244
300
  main()
@@ -34,13 +34,19 @@ extensions = [
34
34
  'tdoc.common',
35
35
  ]
36
36
 
37
+ suppress_warnings = [
38
+ 'myst.strikethrough', # Only supported for HTML, but that's all we want
39
+ ]
40
+
37
41
  # Extension options.
38
42
  graphviz_output_format = 'svg'
39
43
  todo_include_todos = True
40
44
 
41
45
  # MyST options.
42
- myst_enable_extensions = [
46
+ myst_enable_extensions = {
43
47
  'amsmath',
48
+ 'attrs_block',
49
+ 'attrs_inline',
44
50
  'colon_fence',
45
51
  'deflist',
46
52
  'dollarmath',
@@ -52,8 +58,9 @@ myst_enable_extensions = [
52
58
  'strikethrough',
53
59
  'substitution',
54
60
  'tasklist',
55
- ]
61
+ }
56
62
  myst_dmath_double_inline = True
63
+ myst_heading_anchors = 6
57
64
 
58
65
  # HTML rendering options.
59
66
  html_show_sphinx = False
@@ -6,6 +6,10 @@
6
6
  display: none !important;
7
7
  }
8
8
 
9
+ .line-height-normal .highlight pre {
10
+ line-height: normal !important;
11
+ }
12
+
9
13
  /* Set the maximum width of sidebars instead of a fixed width. */
10
14
  div.sidebar, aside.sidebar {
11
15
  max-width: 40%;
@@ -1 +0,0 @@
1
- 267a6c8ad66dde08f2b75d2d82d0d2985ca8f137 0.2
@@ -1,9 +0,0 @@
1
- <!-- Copyright 2024 Caroline Blank <caro@c-space.org> -->
2
- <!-- Copyright 2024 Remy Blank <remy@c-space.org> -->
3
- <!-- SPDX-License-Identifier: MIT -->
4
-
5
- # t-doc - Base commune
6
-
7
- Ce package contient la fonctionnalité commune aux documents basés sur t-doc.
8
-
9
- Ce logiciel est distribué sous la licence [MIT](LICENSE.txt).
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes