sphinx-needs
sphinx-needs copied to clipboard
Changed needs.json doesn’t trigger incremental build
This is a user expected behavior, but might be a tough one to crack.
If an imported needs.json is changed it does not trigger incremental read/write of the rST which includes it.
An included plantuml file, for example, does this.
Puhh, that's not so easy. The problem is, that an updated needs.json can have impact on so many pages and it is hard or maybe even impossible to figure out, which pages are infected.
To make this safe, I only see the possibility to force Sphinx to read and write all files again. if a change in needs.json is detected. And from the user perspective, I'm not sure if such a behavior shall be forced (full build can take a long time) or the user is responsible to perform a clean build, whenever the generated results gets "official".
As far as I know, sphinx-plantuml creates the image names based on a hash of a plantuml file. So if the plantuml file changes, the image name changes as well, which triggers sphinx to rebuild the page. But I'm not 100% and will take a look again into their concept.
You are right. I feel the effort to get this working would be too high compared to the benefits and it will never be perfect. Therefore, low prio from my side.
For me it is not clear, why all files must be read and written again. I assume, updated needs.json must trigger only that files which include needs.json with needimport
?
Then output files must only we written which are affected. Is this not comparable with a rst file which contains a lot of needs? If this rst file changes, the dependent files must also be written again.
What is the difference between needs define in rst or needs.json (in imported to a rst)?
@Chriner Sorry for the late response. Missed this ticket.
It is not different for the needs itself. But there may be needtables and co. on other pages, which are based on these imported needs. But that problem also exists, if changes are made to a single rst.
Okay, got an idea and here is a small concept.
Concept
-
Sphinx-Needs must create and store a hash value for each needs.json file, which get used somehow (during needimport call) (the hash gets created, when a needimport directive is executed) Elements to store: need.json path, rst-path, need.json hash
-
On each startup of Sphinx-Needs, it must check if
-
stored need-json files still exist
-
recreate the hash of each stored need.json file
-
if hashes do not match, tell Sphinx to recreate the related page
Sounds doable :)
When I read the description of @danwos again, it just came to my mind we might not need the hash of the json file. Wouldn't it be enough to store time and date and compare it. When the file is updated it shall have a newer timestamp.