elastic / elastic/docs-builder
[Feature Request]: include directive
- Dominant language
- C#
- Stars
- 24
- Forks
- 44
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 146
Description
### Prerequisites
- [x] I have searched existing issues to ensure this feature hasn't already been requested
- [x] I have tested using the latest version of docs-builder
### What problem are you trying to solve?
This is a follow-up to #16. The `include` (or `includeliteral`) directive should allow extracting segments of a file, so that code snippets can be extracted from actual code file that are compiled and tested.
At a bare minimum, the `start-after` and `end-before` attributes should be implemented, so that we can use the same tagging system as with Asciidoc (which is also much more robust than line numbers).
The included files should also be able to live outside in the project's test source tree which is generally outside of the docs directory. The previous docs system allowed to configure a list of directories to sparse-checkout for that purpose.
In the meantime, for the Java client, I implemented a workaround with [an `include-code` pseudo-directive](https://github.com/elastic/elasticsearch-java/blob/c18017112bd237de29264404ba2930e01cae7f5f/docs/reference/getting-started.md?plain=1#L51-L66) that is implemented using a file preprocessor that will append the [target source snippet](https://github.com/elastic/elasticsearch-java/blob/c18017112bd237de29264404ba2930e01cae7f5f/java-client/src/test/java/co/elastic/clients/documentation/getting_started/ConnectingTest.java#L41-L55) below the pseudo-directive.
### Proposed Solution
See above.
### Examples and Research
_No response_
### Alternative Solutions
_No response_
### Additional Context
_No response_
### How important is this feature to you?
Critical (even if we have a workaround)
Contributor guide
Assessment
This issue has not been assessed yet.