-
Notifications
You must be signed in to change notification settings - Fork 36
feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes #2539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(backend/sdoc_source_code): Support merging sdoc nodes with soure nodes #2539
Conversation
628dd4a to
5a81c92
Compare
There was a problem hiding this 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.
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. |
5a81c92 to
035fc5b
Compare
|
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 |
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.
035fc5b to
c5e1097
Compare
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 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? EDIT 5: Fixed with 86a4951. |
c5e1097 to
ad09965
Compare
ad09965 to
9de1729
Compare
…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.
9de1729 to
86a4951
Compare
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:
The PR includes two related changes as groundwork. Let me know if you prefer separate pull requests.