thi-ng / umbrella

⛱ Broadly scoped ecosystem & mono-repository of 199 TypeScript projects (and ~180 examples) for general purpose, functional, data driven development
https://thi.ng
Apache License 2.0
3.35k stars 149 forks source link

[tangle] add transclusion support aka replace code block body w/ external file contents #365

Closed postspectacular closed 1 year ago

postspectacular commented 1 year ago

Currently, tangle can only extract code blocks from a source (Markdown) file. For some use cases it would be beneficial to provide the opposite operation, i.e. replacing the body of a code block with the contents of a give file:

# Example markdown source file

```ts tangle:export/foo.ts
// some code to be extracted
// ...
```

```ts transclude:export/bar.ts
// content of this block will be replaced w/ file contents 
```

A concrete use case for this is the @thi.ng/wasm-api-bindgen readme, where the example JSON type specifications for the code generator are (already) tangled from the readme, however, at current, the generated source code must be manually copied back into the readme. Having transclusion support would allow this to be automated. Same goes for the various examples in the book/courseware docs...

Related:

postspectacular commented 1 year ago

Closing this since meanwhile added thi.ng/transclude as individual package, and not complicating the design of tangle any further...