t-doc-common 0.6.dev2__tar.gz → 0.7__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 (61) hide show
  1. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/.gitignore +1 -1
  2. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/.hgignore +1 -1
  3. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/.hgtags +2 -0
  4. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/LICENSES.deps.txt +49 -49
  5. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/PKG-INFO +1 -1
  6. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/docs/demo/sql.md +18 -2
  7. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/package-lock.json +20 -17
  8. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/package.json +7 -3
  9. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/pyproject.toml +6 -2
  10. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/rollup.config.mjs +9 -15
  11. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/__init__.py +9 -4
  12. t_doc_common-0.7/tdoc/common/scripts/tdoc-editor.js +103 -0
  13. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/static/styles/t-doc.css +30 -5
  14. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/static/tdoc-sql.js +73 -33
  15. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3-bundler-friendly.mjs +19 -10
  16. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3-node.mjs +7 -7
  17. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3-opfs-async-proxy.js +14 -147
  18. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3.js +19 -10
  19. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3.mjs +19 -10
  20. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3.wasm +0 -0
  21. t_doc_common-0.7/tdoc/common/static.gen/tdoc-editor.js +30270 -0
  22. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tools/hatch_hooks.py +6 -2
  23. t_doc_common-0.6.dev2/.gitmodules +0 -3
  24. t_doc_common-0.6.dev2/.hgsub +0 -1
  25. t_doc_common-0.6.dev2/.hgsubstate +0 -1
  26. t_doc_common-0.6.dev2/ext/sqlite-wasm/.gitignore +0 -43
  27. t_doc_common-0.6.dev2/ext/sqlite-wasm/.prettierrc +0 -20
  28. t_doc_common-0.6.dev2/ext/sqlite-wasm/README.md +0 -234
  29. t_doc_common-0.6.dev2/ext/sqlite-wasm/bin/index.js +0 -61
  30. t_doc_common-0.6.dev2/ext/sqlite-wasm/demo/index.html +0 -19
  31. t_doc_common-0.6.dev2/ext/sqlite-wasm/demo/main-thread.js +0 -53
  32. t_doc_common-0.6.dev2/ext/sqlite-wasm/demo/module-workers-polyfill.min.js +0 -218
  33. t_doc_common-0.6.dev2/ext/sqlite-wasm/demo/script.js +0 -42
  34. t_doc_common-0.6.dev2/ext/sqlite-wasm/demo/worker.js +0 -56
  35. t_doc_common-0.6.dev2/ext/sqlite-wasm/demo/wrapped-worker.js +0 -72
  36. t_doc_common-0.6.dev2/ext/sqlite-wasm/index.d.ts +0 -8073
  37. t_doc_common-0.6.dev2/ext/sqlite-wasm/index.mjs +0 -7
  38. t_doc_common-0.6.dev2/ext/sqlite-wasm/package-lock.json +0 -1993
  39. t_doc_common-0.6.dev2/ext/sqlite-wasm/package.json +0 -65
  40. t_doc_common-0.6.dev2/tdoc/common/scripts/tdoc-editor.js +0 -27
  41. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/.github/workflows/deploy-github-pages.yml +0 -0
  42. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/.github/workflows/publish.yml +0 -0
  43. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/LICENSE.txt +0 -0
  44. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/README.md +0 -0
  45. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/docs/conf.py +0 -0
  46. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/docs/demo/index.md +0 -0
  47. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/docs/development.md +0 -0
  48. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/docs/edit.md +0 -0
  49. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/docs/index.md +0 -0
  50. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/docs/install.md +0 -0
  51. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/serve.bat +0 -0
  52. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/serve.desktop +0 -0
  53. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/cli.py +0 -0
  54. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/components/copyright.html +0 -0
  55. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/defaults.py +0 -0
  56. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3-worker1-bundler-friendly.mjs +0 -0
  57. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3-worker1-promiser.js +0 -0
  58. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3-worker1-promiser.mjs +0 -0
  59. {t_doc_common-0.6.dev2/ext/sqlite-wasm/sqlite-wasm/jswasm → t_doc_common-0.7/tdoc/common/static.gen}/sqlite3-worker1.js +0 -0
  60. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/theme.toml +0 -0
  61. {t_doc_common-0.6.dev2 → t_doc_common-0.7}/tdoc/common/util.py +0 -0
@@ -1,4 +1,3 @@
1
- *.gen.*
2
1
  *.orig
3
2
  __pycache__
4
3
 
@@ -6,4 +5,5 @@ __pycache__
6
5
  /_build/
7
6
  /dist/
8
7
  /node_modules/
8
+ /tdoc/common/static.gen/
9
9
  /tmp/
@@ -1,5 +1,4 @@
1
1
  syntax: glob
2
- *.gen.*
3
2
  *.orig
4
3
  __pycache__
5
4
 
@@ -8,4 +7,5 @@ syntax: regexp
8
7
  ^_build/
9
8
  ^dist/
10
9
  ^node_modules/
10
+ ^tdoc/common/static\.gen/
11
11
  ^tmp/
@@ -2,3 +2,5 @@
2
2
  ea2973414a3779c7ffbed73279ab8d811c795268 0.3
3
3
  dcb01efb897d0e04063b92998c17b02b587761c7 0.4
4
4
  e4ac6c10dd9194ff48c95d82e462e45bbd651ef1 0.5
5
+ 145a6ae1f8e1a445a9a13c687c17bf587b48522f 0.6
6
+ f5adc3e31d10e2b5478fe2e041b936159dd5c1c0 0.7
@@ -233,12 +233,12 @@ THE SOFTWARE.
233
233
 
234
234
  ---
235
235
 
236
- Name: @codemirror/commands
237
- Version: 6.6.1
236
+ Name: @codemirror/autocomplete
237
+ Version: 6.18.0
238
238
  License: MIT
239
239
  Private: false
240
- Description: Collection of editing commands for the CodeMirror code editor
241
- Repository: https://github.com/codemirror/commands.git
240
+ Description: Autocompletion for the CodeMirror code editor
241
+ Repository: https://github.com/codemirror/autocomplete.git
242
242
  Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
243
243
  License Copyright:
244
244
  ===
@@ -267,18 +267,19 @@ THE SOFTWARE.
267
267
 
268
268
  ---
269
269
 
270
- Name: crelt
271
- Version: 1.0.6
270
+ Name: @codemirror/commands
271
+ Version: 6.6.1
272
272
  License: MIT
273
273
  Private: false
274
- Description: Tiny DOM-element-creation utility
275
- Repository: git+https://github.com/marijnh/crelt.git
276
- Homepage: https://github.com/marijnh/crelt#readme
277
- Author: Marijn Haverbeke <marijn@haverbeke.berlin>
274
+ Description: Collection of editing commands for the CodeMirror code editor
275
+ Repository: https://github.com/codemirror/commands.git
276
+ Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
278
277
  License Copyright:
279
278
  ===
280
279
 
281
- Copyright (C) 2020 by Marijn Haverbeke <marijn@haverbeke.berlin>
280
+ MIT License
281
+
282
+ Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
282
283
 
283
284
  Permission is hereby granted, free of charge, to any person obtaining a copy
284
285
  of this software and associated documentation files (the "Software"), to deal
@@ -300,19 +301,18 @@ THE SOFTWARE.
300
301
 
301
302
  ---
302
303
 
303
- Name: @codemirror/search
304
- Version: 6.5.6
304
+ Name: crelt
305
+ Version: 1.0.6
305
306
  License: MIT
306
307
  Private: false
307
- Description: Search functionality for the CodeMirror code editor
308
- Repository: https://github.com/codemirror/search.git
309
- Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
308
+ Description: Tiny DOM-element-creation utility
309
+ Repository: git+https://github.com/marijnh/crelt.git
310
+ Homepage: https://github.com/marijnh/crelt#readme
311
+ Author: Marijn Haverbeke <marijn@haverbeke.berlin>
310
312
  License Copyright:
311
313
  ===
312
314
 
313
- MIT License
314
-
315
- Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
315
+ Copyright (C) 2020 by Marijn Haverbeke <marijn@haverbeke.berlin>
316
316
 
317
317
  Permission is hereby granted, free of charge, to any person obtaining a copy
318
318
  of this software and associated documentation files (the "Software"), to deal
@@ -334,12 +334,12 @@ THE SOFTWARE.
334
334
 
335
335
  ---
336
336
 
337
- Name: @codemirror/autocomplete
338
- Version: 6.18.0
337
+ Name: @codemirror/lint
338
+ Version: 6.8.1
339
339
  License: MIT
340
340
  Private: false
341
- Description: Autocompletion for the CodeMirror code editor
342
- Repository: https://github.com/codemirror/autocomplete.git
341
+ Description: Linting support for the CodeMirror code editor
342
+ Repository: https://github.com/codemirror/lint.git
343
343
  Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
344
344
  License Copyright:
345
345
  ===
@@ -368,12 +368,12 @@ THE SOFTWARE.
368
368
 
369
369
  ---
370
370
 
371
- Name: @codemirror/lint
372
- Version: 6.8.1
371
+ Name: @codemirror/search
372
+ Version: 6.5.6
373
373
  License: MIT
374
374
  Private: false
375
- Description: Linting support for the CodeMirror code editor
376
- Repository: https://github.com/codemirror/lint.git
375
+ Description: Search functionality for the CodeMirror code editor
376
+ Repository: https://github.com/codemirror/search.git
377
377
  Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
378
378
  License Copyright:
379
379
  ===
@@ -402,19 +402,19 @@ THE SOFTWARE.
402
402
 
403
403
  ---
404
404
 
405
- Name: codemirror
406
- Version: 6.0.1
405
+ Name: @codemirror/theme-one-dark
406
+ Version: 6.1.2
407
407
  License: MIT
408
408
  Private: false
409
- Description: Basic configuration for the CodeMirror code editor
410
- Repository: https://github.com/codemirror/basic-setup.git
411
- Author: Marijn Haverbeke <marijnh@gmail.com> (http://marijnhaverbeke.nl)
409
+ Description: One Dark theme for the CodeMirror code editor
410
+ Repository: https://github.com/codemirror/theme-one-dark.git
411
+ Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
412
412
  License Copyright:
413
413
  ===
414
414
 
415
415
  MIT License
416
416
 
417
- Copyright (C) 2018-2021 by Marijn Haverbeke <marijnh@gmail.com> and others
417
+ Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
418
418
 
419
419
  Permission is hereby granted, free of charge, to any person obtaining a copy
420
420
  of this software and associated documentation files (the "Software"), to deal
@@ -572,19 +572,19 @@ THE SOFTWARE.
572
572
 
573
573
  ---
574
574
 
575
- Name: @codemirror/lang-html
576
- Version: 6.4.9
575
+ Name: @lezer/javascript
576
+ Version: 1.4.17
577
577
  License: MIT
578
578
  Private: false
579
- Description: HTML language support for the CodeMirror code editor
580
- Repository: https://github.com/codemirror/lang-html.git
581
- Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
579
+ Description: lezer-based JavaScript grammar
580
+ Repository: https://github.com/lezer-parser/javascript.git
581
+ Author: Marijn Haverbeke <marijn@haverbeke.berlin>
582
582
  License Copyright:
583
583
  ===
584
584
 
585
585
  MIT License
586
586
 
587
- Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
587
+ Copyright (C) 2018 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
588
588
 
589
589
  Permission is hereby granted, free of charge, to any person obtaining a copy
590
590
  of this software and associated documentation files (the "Software"), to deal
@@ -606,19 +606,19 @@ THE SOFTWARE.
606
606
 
607
607
  ---
608
608
 
609
- Name: @lezer/javascript
610
- Version: 1.4.17
609
+ Name: @codemirror/lang-javascript
610
+ Version: 6.2.2
611
611
  License: MIT
612
612
  Private: false
613
- Description: lezer-based JavaScript grammar
614
- Repository: https://github.com/lezer-parser/javascript.git
615
- Author: Marijn Haverbeke <marijn@haverbeke.berlin>
613
+ Description: JavaScript language support for the CodeMirror code editor
614
+ Repository: https://github.com/codemirror/lang-javascript.git
615
+ Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
616
616
  License Copyright:
617
617
  ===
618
618
 
619
619
  MIT License
620
620
 
621
- Copyright (C) 2018 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
621
+ Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
622
622
 
623
623
  Permission is hereby granted, free of charge, to any person obtaining a copy
624
624
  of this software and associated documentation files (the "Software"), to deal
@@ -640,12 +640,12 @@ THE SOFTWARE.
640
640
 
641
641
  ---
642
642
 
643
- Name: @codemirror/lang-javascript
644
- Version: 6.2.2
643
+ Name: @codemirror/lang-html
644
+ Version: 6.4.9
645
645
  License: MIT
646
646
  Private: false
647
- Description: JavaScript language support for the CodeMirror code editor
648
- Repository: https://github.com/codemirror/lang-javascript.git
647
+ Description: HTML language support for the CodeMirror code editor
648
+ Repository: https://github.com/codemirror/lang-html.git
649
649
  Author: Marijn Haverbeke <marijn@haverbeke.berlin> (http://marijnhaverbeke.nl)
650
650
  License Copyright:
651
651
  ===
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: t-doc-common
3
- Version: 0.6.dev2
3
+ Version: 0.7
4
4
  Summary: Common functionality for t-doc
5
5
  Project-URL: Code, https://github.com/t-docs/common
6
6
  Project-URL: Documentation, https://t-doc.org/common/
@@ -21,10 +21,13 @@ References an `{exec}` block to be executed before this block, in the same
21
21
  environment. The referenced block can itself have an `:after:` option, forming
22
22
  a chain of blocks to execute in the environment.
23
23
  ```
24
+ ```{rst:directive:option} editable
25
+ When set, the `{exec}` block is made editable.
26
+ ```
24
27
  ```{rst:directive:option} when: value
25
28
  :type: click | load | never
26
- Determines when the block's code is executed: on a click by the user (`click`),
27
- when the page loads (`load`) or not at all (`never`).
29
+ Determines when the block's code is executed: on user request (`click`, the
30
+ default), when the page loads (`load`) or not at all (`never`).
28
31
  ```
29
32
  ````
30
33
 
@@ -110,3 +113,16 @@ select * from countries where country_code = 'LI';
110
113
  They can also be executed immediately on load (`:when: load`) or not at all
111
114
  (`:when: never`, useful for database definitions that are referenced by other
112
115
  blocks). In these cases, no controls aren displayed.
116
+
117
+ ## Editable blocks
118
+
119
+ Blocks can be made editable with the `:editable:` option.
120
+
121
+ ```{exec} sql
122
+ :after: sql-countries
123
+ :when: load
124
+ :editable:
125
+ select * from countries
126
+ where population > 10000000
127
+ order by country_code;
128
+ ```
@@ -6,15 +6,21 @@
6
6
  "": {
7
7
  "name": "t-doc-common",
8
8
  "devDependencies": {
9
+ "@codemirror/autocomplete": "^6.18.0",
10
+ "@codemirror/commands": "^6.6.1",
9
11
  "@codemirror/lang-css": "^6.2.1",
10
12
  "@codemirror/lang-html": "^6.4.9",
11
13
  "@codemirror/lang-javascript": "^6.2.2",
12
14
  "@codemirror/lang-python": "^6.1.6",
13
15
  "@codemirror/lang-sql": "^6.7.1",
16
+ "@codemirror/language": "^6.10.2",
17
+ "@codemirror/lint": "^6.8.1",
18
+ "@codemirror/search": "^6.5.6",
19
+ "@codemirror/state": "^6.4.1",
20
+ "@codemirror/theme-one-dark": "^6.1.2",
14
21
  "@codemirror/view": "^6.33.0",
15
22
  "@rollup/plugin-node-resolve": "^15.2.3",
16
23
  "@sqlite.org/sqlite-wasm": "^3.46.1-build1",
17
- "codemirror": "^6.0.1",
18
24
  "rollup": "^4.21.2",
19
25
  "rollup-plugin-license": "^3.5.2"
20
26
  }
@@ -174,6 +180,19 @@
174
180
  "dev": true,
175
181
  "license": "MIT"
176
182
  },
183
+ "node_modules/@codemirror/theme-one-dark": {
184
+ "version": "6.1.2",
185
+ "resolved": "https://registry.npmjs.org/@codemirror/theme-one-dark/-/theme-one-dark-6.1.2.tgz",
186
+ "integrity": "sha512-F+sH0X16j/qFLMAfbciKTxVOwkdAS336b7AXTKOZhy8BR3eH/RelsnLgLFINrpST63mmN2OuwUt0W2ndUgYwUA==",
187
+ "dev": true,
188
+ "license": "MIT",
189
+ "dependencies": {
190
+ "@codemirror/language": "^6.0.0",
191
+ "@codemirror/state": "^6.0.0",
192
+ "@codemirror/view": "^6.0.0",
193
+ "@lezer/highlight": "^1.0.0"
194
+ }
195
+ },
177
196
  "node_modules/@codemirror/view": {
178
197
  "version": "6.33.0",
179
198
  "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.33.0.tgz",
@@ -588,22 +607,6 @@
588
607
  "url": "https://github.com/sponsors/sindresorhus"
589
608
  }
590
609
  },
591
- "node_modules/codemirror": {
592
- "version": "6.0.1",
593
- "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz",
594
- "integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==",
595
- "dev": true,
596
- "license": "MIT",
597
- "dependencies": {
598
- "@codemirror/autocomplete": "^6.0.0",
599
- "@codemirror/commands": "^6.0.0",
600
- "@codemirror/language": "^6.0.0",
601
- "@codemirror/lint": "^6.0.0",
602
- "@codemirror/search": "^6.0.0",
603
- "@codemirror/state": "^6.0.0",
604
- "@codemirror/view": "^6.0.0"
605
- }
606
- },
607
610
  "node_modules/commenting": {
608
611
  "version": "1.1.0",
609
612
  "resolved": "https://registry.npmjs.org/commenting/-/commenting-1.1.0.tgz",
@@ -1,16 +1,20 @@
1
1
  {
2
- "dependencies": {
3
- },
4
2
  "devDependencies": {
3
+ "@codemirror/autocomplete": "^6.18.0",
4
+ "@codemirror/commands": "^6.6.1",
5
5
  "@codemirror/lang-css": "^6.2.1",
6
6
  "@codemirror/lang-html": "^6.4.9",
7
7
  "@codemirror/lang-javascript": "^6.2.2",
8
8
  "@codemirror/lang-python": "^6.1.6",
9
9
  "@codemirror/lang-sql": "^6.7.1",
10
+ "@codemirror/language": "^6.10.2",
11
+ "@codemirror/lint": "^6.8.1",
12
+ "@codemirror/search": "^6.5.6",
13
+ "@codemirror/state": "^6.4.1",
14
+ "@codemirror/theme-one-dark": "^6.1.2",
10
15
  "@codemirror/view": "^6.33.0",
11
16
  "@rollup/plugin-node-resolve": "^15.2.3",
12
17
  "@sqlite.org/sqlite-wasm": "^3.46.1-build1",
13
- "codemirror": "^6.0.1",
14
18
  "rollup": "^4.21.2",
15
19
  "rollup-plugin-license": "^3.5.2"
16
20
  },
@@ -53,10 +53,14 @@ path = "tools/hatch_hooks.py"
53
53
  path = "tools/hatch_hooks.py"
54
54
 
55
55
  [tool.hatch.build.targets.sdist]
56
+ artifacts = [
57
+ "/tdoc/common/static.gen/",
58
+ ]
56
59
 
57
60
  [tool.hatch.build.targets.wheel]
58
61
  only-include = [
59
- "ext/sqlite-wasm/sqlite-wasm/jswasm",
60
62
  "tdoc",
61
63
  ]
62
- sources."ext/sqlite-wasm/sqlite-wasm" = "tdoc/common/static"
64
+ artifacts = [
65
+ "/tdoc/common/static.gen/",
66
+ ]
@@ -1,8 +1,8 @@
1
1
  // Copyright 2024 Remy Blank <remy@c-space.org>
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import path from 'node:path';
5
- import url from 'node:url';
4
+ import * as path from 'node:path';
5
+ import * as url from 'node:url';
6
6
  import resolve from '@rollup/plugin-node-resolve';
7
7
  import license from 'rollup-plugin-license';
8
8
 
@@ -11,29 +11,23 @@ import license from 'rollup-plugin-license';
11
11
  const __filename = import.meta.filename || url.fileURLToPath(import.meta.url)
12
12
  const __dirname = import.meta.dirname || path.dirname(__filename)
13
13
 
14
+ // TODO: Package @sqlite.org/sqlite-wasm. Or maybe it must be an external
15
+ // because of the worker module and .wasm.
16
+
14
17
  export default {
15
18
  input: "./tdoc/common/scripts/tdoc-editor.js",
16
19
  output: {
17
- chunkFileNames: '[name].gen.js',
20
+ chunkFileNames: '[name].js',
18
21
  compact: true,
19
- dir: './tdoc/common/static/',
20
- entryFileNames: '[name].gen.js',
22
+ dir: './tdoc/common/static.gen/',
23
+ entryFileNames: '[name].js',
21
24
  format: 'es',
22
25
  generatedCode: {
23
26
  arrowFunctions: true,
24
27
  constBindings: true,
25
28
  objectShorthand: true,
26
29
  },
27
- // TODO: Package @sqlite.org/sqlite-wasm as well. Or maybe it must
28
- // be an external because of the worker module and .wasm
29
- manualChunks: {
30
- 'tdoc-cm': ['codemirror'],
31
- 'tdoc-cm-css': ['@codemirror/lang-css'],
32
- 'tdoc-cm-html': ['@codemirror/lang-html'],
33
- 'tdoc-cm-javascript': ['@codemirror/lang-javascript'],
34
- 'tdoc-cm-python': ['@codemirror/lang-python'],
35
- 'tdoc-cm-sql': ['@codemirror/lang-sql'],
36
- },
30
+ manualChunks: {},
37
31
  },
38
32
  plugins: [
39
33
  resolve(),
@@ -10,7 +10,7 @@ from sphinx.directives.code import CodeBlock
10
10
  from sphinx.util import logging
11
11
 
12
12
  __project__ = 't-doc-common'
13
- __version__ = '0.6.dev2'
13
+ __version__ = '0.7'
14
14
 
15
15
  _common = pathlib.Path(__file__).absolute().parent
16
16
  _root = _common.parent.parent
@@ -65,9 +65,11 @@ def on_config_inited(app, config):
65
65
  def on_builder_inited(app):
66
66
  # Add our own static paths.
67
67
  app.config.html_static_path.append(str(_common / 'static'))
68
- sw = _root / 'ext' / 'sqlite-wasm' / 'sqlite-wasm'
69
- if (sw / 'jswasm').is_dir():
70
- app.config.html_static_path.append(str(sw))
68
+ app.config.html_static_path.append(str(_common / 'static.gen'))
69
+ sqlite_path = (_root / 'node_modules' / '@sqlite.org' / 'sqlite-wasm'
70
+ / 'sqlite-wasm' / 'jswasm')
71
+ if sqlite_path.is_dir():
72
+ app.config.html_static_path.append(str(sqlite_path))
71
73
 
72
74
 
73
75
  def on_html_page_context(app, page, template, context, doctree):
@@ -95,6 +97,7 @@ class Exec(CodeBlock):
95
97
 
96
98
  option_spec = CodeBlock.option_spec | {
97
99
  'after': directives.unchanged,
100
+ 'editable': directives.flag,
98
101
  'when': lambda c: directives.choice(c, ('click', 'load', 'never')),
99
102
  }
100
103
 
@@ -119,6 +122,8 @@ class Exec(CodeBlock):
119
122
  if after := self.options.get('after'):
120
123
  node['after'] = after
121
124
  node['when'] = self.options.get('when', 'click')
125
+ if 'editable' in self.options:
126
+ node['classes'] += ['tdoc-editable']
122
127
 
123
128
 
124
129
  def check_after_references(app, doctree, docname):
@@ -0,0 +1,103 @@
1
+ // Copyright 2024 Remy Blank <remy@c-space.org>
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import * as autocomplete from '@codemirror/autocomplete';
5
+ import * as commands from '@codemirror/commands';
6
+ import * as language from '@codemirror/language';
7
+ import * as lint from '@codemirror/lint';
8
+ import * as search from '@codemirror/search';
9
+ import * as state from '@codemirror/state';
10
+ import * as view from '@codemirror/view';
11
+
12
+ import {oneDark} from '@codemirror/theme-one-dark';
13
+
14
+ import {css} from '@codemirror/lang-css';
15
+ import {html} from '@codemirror/lang-html';
16
+ import {javascript} from '@codemirror/lang-javascript';
17
+ import {python} from '@codemirror/lang-python';
18
+ import {sql} from '@codemirror/lang-sql';
19
+
20
+ const languages = {css, html, javascript, python, sql};
21
+
22
+ // React to theme changes and update all editor themes as well.
23
+ const theme = new state.Compartment();
24
+ const lightTheme = view.EditorView.theme({}, {dark: false});
25
+ const darkTheme = oneDark;
26
+
27
+ function currentTheme() {
28
+ return document.querySelector('html').dataset.theme === 'dark' ?
29
+ darkTheme : lightTheme;
30
+ }
31
+
32
+ let curTheme = currentTheme();
33
+
34
+ const obs = new MutationObserver((mutations) => {
35
+ for (const mut of mutations) {
36
+ if (mut.attributeName !== 'data-theme') continue;
37
+ const newTheme = currentTheme();
38
+ if (newTheme === curTheme) break;
39
+ curTheme = newTheme;
40
+ for (const div of document.querySelectorAll('div.cm-editor')) {
41
+ const editor = div.tdocEditor;
42
+ editor.dispatch({effects: theme.reconfigure(curTheme)});
43
+ }
44
+ break;
45
+ }
46
+ });
47
+ obs.observe(document.querySelector('html'), {attributes: true});
48
+
49
+ // Return the editor extensions for the given config.
50
+ function extensions(config) {
51
+ return [
52
+ theme.of(currentTheme()),
53
+ autocomplete.autocompletion(),
54
+ autocomplete.closeBrackets(),
55
+ commands.history(),
56
+ language.bracketMatching(),
57
+ language.foldGutter(),
58
+ language.indentOnInput(),
59
+ language.indentUnit.of(' '),
60
+ language.syntaxHighlighting(language.defaultHighlightStyle,
61
+ {fallback: true}),
62
+ search.highlightSelectionMatches(),
63
+ state.EditorState.allowMultipleSelections.of(true),
64
+ state.EditorState.tabSize.of(4),
65
+ view.crosshairCursor(),
66
+ view.drawSelection(),
67
+ view.dropCursor(),
68
+ view.highlightActiveLine(),
69
+ view.highlightActiveLineGutter(),
70
+ view.highlightSpecialChars(),
71
+ view.keymap.of([
72
+ ...(config.onRun ? [{key: "Shift-Enter", run: config.onRun}] : []),
73
+ ...autocomplete.closeBracketsKeymap,
74
+ ...autocomplete.completionKeymap,
75
+ ...commands.defaultKeymap,
76
+ ...commands.historyKeymap,
77
+ commands.indentWithTab,
78
+ ...language.foldKeymap,
79
+ ...lint.lintKeymap,
80
+ ...search.searchKeymap,
81
+ ]),
82
+ view.lineNumbers(),
83
+ view.rectangularSelection(),
84
+ view.EditorView.lineWrapping,
85
+ (languages[config.language] || (() => []))(),
86
+ ];
87
+ }
88
+
89
+ // Add an editor to the given element.
90
+ export function addEditor(parent, config) {
91
+ const editor = new view.EditorView({
92
+ doc: config.text || '',
93
+ extensions: extensions(config),
94
+ parent,
95
+ });
96
+ parent.querySelector('div.cm-editor').tdocEditor = editor;
97
+ return editor;
98
+ }
99
+
100
+ // Find an editor in or below the given element.
101
+ export function findEditor(el) {
102
+ return el.querySelector('div.cm-editor')?.tdocEditor;
103
+ }
@@ -26,6 +26,31 @@ div.sidebar, aside.sidebar {
26
26
  background-color: var(--pst-color-table-row-hover-bg);
27
27
  }
28
28
 
29
+ /* Code blocks */
30
+ div.highlight pre {
31
+ padding: 0.7rem;
32
+ }
33
+
34
+ /* Editor */
35
+ div.tdoc-exec.tdoc-editable div.highlight pre,
36
+ div.tdoc-exec.tdoc-editable div.highlight button.copybtn {
37
+ display: none;
38
+ }
39
+ div.tdoc-exec.tdoc-editable div.cm-editor {
40
+ border-radius: 0.25rem;
41
+ border: 1px solid var(--pst-color-border);
42
+ }
43
+ html[data-theme=dark] div.tdoc-exec.tdoc-editable div.cm-editor {
44
+ background-color: var(--pst-color-surface);
45
+ }
46
+ div.cm-editor.cm-focused {
47
+ outline: none;
48
+ }
49
+ div.cm-editor div.cm-scroller {
50
+ font-family: var(--pst-font-family-monospace);
51
+ font-size: .875em;
52
+ }
53
+
29
54
  /* Execution controls */
30
55
  div[class*=highlight-].tdoc-exec {
31
56
  flex-direction: row;
@@ -39,9 +64,9 @@ div.tdoc-exec-controls {
39
64
  margin-left: 0.3rem;
40
65
  }
41
66
  div.tdoc-exec-controls button {
42
- aspect-ratio: 1;
67
+ width: 1.8rem;
68
+ height: 1.8rem;
43
69
  border-radius: 0.25rem;
44
- padding: 0.3rem;
45
70
  border: 1px solid var(--pst-color-border);
46
71
  background-color: var(--pst-color-surface);
47
72
  font: var(--fa-font-solid);
@@ -50,12 +75,12 @@ div.tdoc-exec-controls button {
50
75
  div.tdoc-exec-controls button:hover {
51
76
  background-color: var(--pst-color-shadow);
52
77
  }
53
- div.tdoc-exec-controls * {
54
- margin-top: 0.3rem;
55
- }
56
78
  div.tdoc-exec-controls *:first-child {
57
79
  margin-top: 0;
58
80
  }
81
+ div.tdoc-exec-controls * {
82
+ margin-top: 0.3rem;
83
+ }
59
84
  div.tdoc-exec-controls button.tdoc-exec-run::before {
60
85
  content: '\f04b';
61
86
  }