Skip to content

Conversation

@haxtibal
Copy link
Contributor

@haxtibal haxtibal commented Oct 30, 2025

This allows to have a (maybe incomplete) definition of a requirement anywhere in the static document tree which is then merged with content from annotated source code at runtime. Previously, StrictDoc would always have auto-generated a new node in an auto-determined document position.

Match criterion is currently the UID. This should be enhanced to MID in an upcoming change.

If the grammar element of sdoc and source code node are different, an error will be raised.

There are two use cases:

  • Control the position (document, section) of a generated source node, as opposed to letting the node generator use an auto generated section.
  • Support "side-car" files where parts of a requirement are defined in *.sdoc, while other parts of the same requirement are inlined with source code. This is a concept from the Linux kernel requirement template proposal.

The PR includes two related changes as groundwork. Let me know if you prefer separate pull requests.

  • Bugfix to make source node file matching work on Windows. The issue existed for long, but went unnoticed since our tests didn't check field values in the rendered docs.
  • Introduce GraphDatabase API to check for presence of a particular link nodeA <-> nodeB.

@haxtibal haxtibal force-pushed the tdmg/merge_source_nodes branch from 628dd4a to 5a81c92 Compare October 30, 2025 13:33
Copy link
Collaborator

@stanislaw stanislaw left a comment

Choose a reason for hiding this comment

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

The change looks good. Just one cosmetic comment.

@stanislaw
Copy link
Collaborator

The change looks good. Just one cosmetic comment.

Regarding the requirements work, feel free to leave it to me, so that merging of this technical work is not blocked. We can polish the L1/L2 missing requirements separately and later.

@haxtibal haxtibal force-pushed the tdmg/merge_source_nodes branch from 5a81c92 to 035fc5b Compare October 30, 2025 17:46
@haxtibal haxtibal changed the title Draft: feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes Oct 30, 2025
@haxtibal
Copy link
Contributor Author

haxtibal commented Oct 30, 2025

Test fails on Windows, but works on Linux? My spontaneous idea is that this has something to do with the UID from file path construction. Maybe some drive letter or backslash has made it into the UID. Do you have a Windows machine to verify? I sadly don't... The expected UID in my test is SRC-NODES-BASE/src/example/example.c/example_1.

@stanislaw
Copy link
Collaborator

Test fails on Windows, but works on Linux? My spontaneous idea is that this has something to do with the UID from file path construction. Maybe some drive letter or backslash has made it into the UID. Do you have a Windows machine to verify? I sadly don't... The expected UID in my test is SRC-NODES-BASE/src/example/example.c/example_1.

I have a Windows machine but I usually avoid opening it 😄

Let me take a look, most of the time it is backward slashes that must be converted to forward slashes.

@stanislaw
Copy link
Collaborator

Test fails on Windows, but works on Linux? My spontaneous idea is that this has something to do with the UID from file path construction. Maybe some drive letter or backslash has made it into the UID. Do you have a Windows machine to verify? I sadly don't... The expected UID in my test is SRC-NODES-BASE/src/example/example.c/example_1.

I have a Windows machine but I usually avoid opening it 😄

Let me take a look, most of the time it is backward slashes that must be converted to forward slashes.

I pushed some basic first WIP/DEBUG checks here to not interfere with your branch: https://github.com/strictdoc-project/strictdoc/actions/runs/18953531691/job/54124265424?pr=2540.

@stanislaw
Copy link
Collaborator

Test fails on Windows, but works on Linux? My spontaneous idea is that this has something to do with the UID from file path construction. Maybe some drive letter or backslash has made it into the UID. Do you have a Windows machine to verify? I sadly don't... The expected UID in my test is SRC-NODES-BASE/src/example/example.c/example_1.

I have a Windows machine but I usually avoid opening it 😄
Let me take a look, most of the time it is backward slashes that must be converted to forward slashes.

I pushed some basic first WIP/DEBUG checks here to not interfere with your branch: https://github.com/strictdoc-project/strictdoc/actions/runs/18953531691/job/54124265424?pr=2540.

Basic debugging doesn't show anything useful 🤔 I will turn on the Windows machine hopefully today still.

The former GraphDatabase.has_link method checked if a node had any link.
Rename it to has_any_link and add a new method to check if there's one
specific link between two nodes. The new method is symmetrical to
create_link.
@haxtibal haxtibal force-pushed the tdmg/merge_source_nodes branch from 035fc5b to c5e1097 Compare October 30, 2025 21:05
@haxtibal
Copy link
Contributor Author

haxtibal commented Oct 30, 2025

Test fails on Windows, but works on Linux? My spontaneous idea is that this has something to do with the UID from file path construction. Maybe some drive letter or backslash has made it into the UID. Do you have a Windows machine to verify? I sadly don't... The expected UID in my test is SRC-NODES-BASE/src/example/example.c/example_1.

I have a Windows machine but I usually avoid opening it 😄
Let me take a look, most of the time it is backward slashes that must be converted to forward slashes.

I pushed some basic first WIP/DEBUG checks here to not interfere with your branch: https://github.com/strictdoc-project/strictdoc/actions/runs/18953531691/job/54124265424?pr=2540.

Basic debugging doesn't show anything useful 🤔 I will turn on the Windows machine hopefully today still.

Thanks!

I've also just added a Debug commit on top to run only the failing test, with print debug added, and stdout/stderr from strictdoc visible.

EDIT1: ... and it doesn't fail 🤔 I've rebased this on top of the has_link change, but that shouldn't change anything. Debug output shows

SRC-NODES-BASE/src/example/example.c/example_1 found in docs, merging with source node from src/example/example.c

so not a file name issue.

...

EDIT 4: Getting closer. The SourceNode passed to merge_sdoc_node_with_source_node has good metadata, but it has no fields. How can that be?

SourceNode(..., fields={}, ...)

EDIT 5: Fixed with 86a4951.

@haxtibal haxtibal force-pushed the tdmg/merge_source_nodes branch from c5e1097 to ad09965 Compare October 30, 2025 21:21
@haxtibal haxtibal changed the title feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes draft: feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes Oct 30, 2025
@haxtibal haxtibal force-pushed the tdmg/merge_source_nodes branch from ad09965 to 9de1729 Compare October 30, 2025 21:39
…e nodes

This allows to have a (maybe incomplete) definition of a requirement
anywhere in the static document tree which is then merged with content
from annotated source code at runtime. Previously, StrictDoc would
always have auto-generated a new node in an auto-determined document
position. Match criterion is currently the UID, this should be enhanced
to MID in an upcoming change. If the grammar element of sdoc and source
code node are different, an error will be raised.

There are two use cases:

- Control the position (document, section) of a generated source node,
  as opposed to letting the node generator use an auto generated section.
- Support "side-car" files where parts of a requirement are defined in
  *.sdoc, while other parts of the same requirement are inlined with
  source code. This is a concept from the Linux kernel requirement
  template proposal.
For config entries like 'source_nodes = [{ "src/" = ... }]' on Windows,
StrictDoc did not find matches since it compared slash path-strings with
backslash path-strings. This effectively disabled the Source Nodes
feature.

We can use pathlib.Path, which automatically creates a WindowsPath or a
PosixPath and supports matching amongst both.

The fix comes with minor refactoring, most notably representing the
config entries as dataclass.
@haxtibal haxtibal force-pushed the tdmg/merge_source_nodes branch from 9de1729 to 86a4951 Compare October 31, 2025 13:36
@haxtibal haxtibal changed the title draft: feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes Oct 31, 2025
@stanislaw stanislaw merged commit 4ae86d3 into strictdoc-project:main Oct 31, 2025
24 checks passed
@stanislaw stanislaw added this to the 2025-Q4 milestone Oct 31, 2025
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.

2 participants