Skip to content

Improve include directive - #1443

Draft
jaapio wants to merge 1 commit into
mainfrom
feature/improved-includes
Draft

jaapio wants to merge 1 commit into
mainfrom
feature/improved-includes

Conversation

@jaapio

@jaapio jaapio commented Oct 28, 2026

Copy link
Copy Markdown
Member

The include directive is a very important directive for large documentation projects. The include now allows nested includes and makes sure the headers are working as expected in the parser context. Which means that headers from includes become part of the parent document, at the level they were include.

The include directive is a very important directive for large documentation
projects. The include now allows nested includes and makes sure the headers are
working as expected in the parser context. Which means that headers from includes
become part of the parent document, at the level they were include.
{
public function __construct(
private readonly DocumentRule $startingRule,
private readonly CodeNodeOptionMapper $codeNodeOptionMapper,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be backward compatible

use function str_contains;
use function trim;

final class IncludeLineSelector

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add unit tests, and improve this code.


public function __construct(
private readonly CodeNodeOptionMapper $codeNodeOptionMapper,
private readonly IncludeLineSelector $lineSelector,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be backward compatible

<h1>Subpage</h1>
<img
src="/subfolder/hero2.svg"
src="/other-parts/hero2.svg"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate with sphinx, is this correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sphinx does copy the files to _images, so this is different. @linawolf do you see an issue in this change? The files are now stored in the same path as they are in the source directory, before we copied them to the target directory.
If you do an include multiple times this would result in multiple times the same image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant