You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developer.md
+44-15Lines changed: 44 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,7 @@ If you are familiar with these tools, you should not find many surprises in the
69
69
That said, there are a couple of concepts used _only_ in this project, that won't be familiar. These are detailed below:
70
70
71
71
(develop-renderers-themes)=
72
+
72
73
### Concepts: Renderers, themes, and templates
73
74
74
75
In the diagram above, we saw that `mystmd` produces websites by:
@@ -107,6 +108,7 @@ MyST has multiple renderers, themes, and templates that allow it to transform My
107
108
- describe the render loop, and how render blocks are registered
108
109
- explain the ThemeProvider
109
110
- explain styling
111
+
110
112
:::
111
113
112
114
#### Example: Adding an "edit this page" button
@@ -247,7 +249,6 @@ During the **Transformations** phase, a number of [enumeration transforms](https
247
249
html_id: label
248
250
```
249
251
250
-
251
252
## Tools used in development
252
253
253
254
`mystmd` is built and developed using:
@@ -264,6 +265,7 @@ These are simply aliases for other commands, defined in the [`package.json` file
264
265
```
265
266
266
267
(developer:mystmd)=
268
+
267
269
## Local development: `mystmd`
268
270
269
271
The `mystmd` libraries and command line tools are written in [TypeScript](https://www.typescriptlang.org/), and require [NodeJS and npm](https://nodejs.org) for local development.
@@ -374,7 +376,7 @@ Note that you can run `npm run dev` from within any folder if you'd like to watc
374
376
375
377
### Approach 2: Static build
376
378
377
-
No content or theme server is required for a static site build. Steps are:
379
+
No content or theme server is required for a static site build. Steps are:
378
380
379
381
1. Build the theme for production
380
382
2. Point your site config to the built theme
@@ -384,7 +386,7 @@ We'll use the mystmd docs site as an example.
384
386
385
387
#### Build theme
386
388
387
-
To build a static site against a local theme, the theme must be built as it would be for production. For that we will use the "make" target
389
+
To build a static site against a local theme, the theme must be built as it would be for production. For that we will use the "make" target
388
390
instead of `npm run`:
389
391
390
392
```{code} bash
@@ -395,7 +397,7 @@ make build-book # because mystmd docs site uses the book theme
395
397
That should produce a production ready version of the book theme under `.deploy/book`.
396
398
397
399
:::{tip}
398
-
While debugging, it helps to work with a theme built against the "development" version of React, which results in unminimized build artifacts (ie preserving whitespace and variable/function names) and more detailed React errors and warnings. For this, tell remix to run in node "development" mode:
400
+
While debugging, it helps to work with a theme built against the "development" version of React, which results in unminimized build artifacts (ie preserving whitespace and variable/function names) and more detailed React errors and warnings. For this, tell remix to run in node "development" mode:
399
401
400
402
```{code} json
401
403
:filename: myst-theme/themes/book/package.json
@@ -404,11 +406,12 @@ While debugging, it helps to work with a theme built against the "development" v
Building a static site against a local theme requires configuring your site's `myst.yml` to point to the built theme's `template.yml`. Using the mystmd docs site as
414
+
Building a static site against a local theme requires configuring your site's `myst.yml` to point to the built theme's `template.yml`. Using the mystmd docs site as
412
415
an example:
413
416
414
417
```{code} yaml
@@ -417,6 +420,7 @@ site:
417
420
# assuming your mystmd and myst-theme working directories are siblings
(NOTE: This is the _built_ template file, under `.deploy`, not the source template)
421
425
422
426
#### Build site
@@ -426,7 +430,8 @@ cd mystmd/docs
426
430
mystmd build --html
427
431
```
428
432
429
-
Then host the static site locally. An easy way is with Python's built-in http server:
433
+
Then host the static site locally. An easy way is with Python's built-in http server:
434
+
430
435
```{code} bash
431
436
cd _build/html
432
437
python3 -m http.server # serves on port 8000 by default
@@ -436,18 +441,18 @@ Finally, browse the site at [http://localhost:8000](http://localhost:8000).
436
441
437
442
## Step Debugging
438
443
439
-
Sometimes the trusty `console.log` (aka print statement) is not sufficient for your debugging needs. In more involved situations, a proper step debugger can be your friend.
444
+
Sometimes the trusty `console.log` (aka print statement) is not sufficient for your debugging needs. In more involved situations, a proper step debugger can be your friend.
440
445
You may have used Firefox or Chrome developer tools to debug in-browser code by adding the `debugger` keyword into your javascript source.
441
446
But what about code that runs in node engine on the server?
442
-
Chrome and Firefox dev tools can _also_ debug server-side javascript. To do this, node must be invoked with the `--inspect`
443
-
or `--inspect-brk` comand-line option. That will cause the node process to open a socket listening for a debugger to connect. If "inspect-brk" is used
444
-
(vs "inspect"), then the process will immediately pause, awaiting a debugger connection. The `debugger` keyword in source will only pause the program if a
447
+
Chrome and Firefox dev tools can _also_ debug server-side javascript. To do this, node must be invoked with the `--inspect`
448
+
or `--inspect-brk` comand-line option. That will cause the node process to open a socket listening for a debugger to connect. If "inspect-brk" is used
449
+
(vs "inspect"), then the process will immediately pause, awaiting a debugger connection. The `debugger` keyword in source will only pause the program if a
445
450
debugger is connected when that keyword is reached.
446
451
447
452
To connect to an awaiting node debug socket, enter into the browser address bar:
448
453
449
454
- Firefox: `about:debugging`, or
450
-
- Chrome: `chrome://inspect`
455
+
- Chrome: `chrome://inspect`
451
456
452
457
That opens a debugger control panel in the browser which should list your awaiting node process as available to connect to (if it has been correctly invoked).
453
458
(NOTE: other browsers and IDEs can also connect as debug inspectors - see Inspector Clients reference below)
@@ -465,6 +470,7 @@ For example, to debug myst-theme's book theme running as a dynamic application s
465
470
// v
466
471
"dev": "npm run dev:copy && npm run build:thebe && concurrently \"npm run dev:css\" \"NODE_OPTIONS=--inspect-brk remix dev\"",
467
472
```
473
+
468
474
Now remove the turbo "--parallel" option, because when turbo runs the theme server in "parallel" (ie multiprocess) mode, each process will attempt to open its own debug socket on the same port, with all but the first failing.
469
475
Then your debugger will only connect to the one that succeeded, with no guarantee any subsequent web request will hit the one process connected to the debugger.
470
476
@@ -483,7 +489,7 @@ To debug myst-theme running server-side in service of a static build:
483
489
484
490
### Debug a mystmd subpackage test suite
485
491
486
-
This requires a handful of options to be passed to vitest to ensure it runs in a single process. For example, to connect a step debugger to a running `myst-transforms` test:
492
+
This requires a handful of options to be passed to vitest to ensure it runs in a single process. For example, to connect a step debugger to a running `myst-transforms` test:
We run a lightweight server at [`api.mystmd.org`](https://api.mystmd.org/) to help users resolve and download templates. The code for this exists at [the `myst-templates/templates` repository](https://github.com/myst-templates/templates).
@@ -525,6 +532,7 @@ To publish a new release of `mystmd`, we do two things:
525
532
We describe each below.
526
533
527
534
(release-npm)=
535
+
528
536
#### Publish a `mystmd` release to NPM
529
537
530
538
- Find the **changesets** PR. This contains a list of the version updates that will be included with this release. [Here's an example of a release PR](https://github.com/jupyter-book/mystmd/pull/1896).
@@ -536,6 +544,7 @@ We describe each below.
536
544
- Next, [make a release on GitHub](#release-github).
537
545
538
546
(release-github)=
547
+
539
548
#### Automated releases on GitHub
540
549
541
550
After a successful NPM release, our [`release.yml` workflow](https://github.com/jupyter-book/mystmd/blob/main/.github/workflows/publish-github-release.yml) will automatically create a new GitHub Release. The release notes are generated using [`github-activity`](https://github.com/cheukting/github-activity) and include a summary of all merged PRs and commits since the previous release.
@@ -544,10 +553,11 @@ After a successful NPM release, our [`release.yml` workflow](https://github.com/
544
553
545
554
You can find the latest releases at: https://github.com/jupyter-book/mystmd/releases
546
555
547
-
When you've confirmed the release has been made, consider sharing it for others to discover!
556
+
When you've confirmed the release has been made, consider sharing it for others to discover!
548
557
549
558
:::{note} Here's an announcement snippet you can copy/paste
550
559
:class: dropdown
560
+
551
561
```md
552
562
TITLE: 🚀 Release: MySTMD v1.3.26
553
563
@@ -558,8 +568,8 @@ The [Jupyter Book project](https://compass.jupyterbook.org) recently made a new
558
568
559
569
See the link above for the release notes on GitHub! Many thanks to the [Jupyter Book team](https://compass.jupyterbook.org/team) for stewarding our development and this release.
560
570
```
561
-
:::
562
571
572
+
:::
563
573
564
574
**Here are a few Jupyter-adjacent spaces to share with** (you can just copy/paste the same text into each):
565
575
@@ -569,6 +579,7 @@ See the link above for the release notes on GitHub! Many thanks to the [Jupyter
569
579
- Social media spaces of your choosing.
570
580
571
581
(release-myst-theme)=
582
+
572
583
### Make a release of the `myst-theme`
573
584
574
585
The process for releasing `myst-theme` infrastructure is similar to the release process for `mystmd`. Here's a brief overview:
@@ -586,6 +597,7 @@ The process for releasing `myst-theme` infrastructure is similar to the release
586
597
We use [Turbo](https://turborepo.com/) to manage our testing and build system.
587
598
588
599
(developer:testing)=
600
+
589
601
### Testing
590
602
591
603
We use [vitest](https://vitest.dev/guide/) for all tests in `mystmd`.
@@ -728,3 +740,20 @@ These packages are [ESM modules](https://gist.github.com/sindresorhus/a39789f988
728
740
-`citation-js-utils`: utility functions to deal with citations.
729
741
-`myst-cli-utils`: shared utils between jtex, and myst-cli.
730
742
-`simple-validators`: validation utilities, that print all sorts of nice warnings.
743
+
744
+
## Tips and tricks
745
+
746
+
### Grepping the codebase
747
+
748
+
While developing, there are a lot of build artifacts lying around,
749
+
making grepping the code harder than it needs to be. Assuming you
0 commit comments