-
Notifications
You must be signed in to change notification settings - Fork 71
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
Namnn/need per id json #960
Namnn/need per id json #960
Conversation
nhatnamnguyengtvthcm
commented
Aug 4, 2023
- In the builder, I build one builder which is name build_needs_id_json to build Json file per need id
- Using command: make docs-html-fast to run.
- Finally, in the "_build" folder will be gen the "needs_id" folder include all file json of need id.
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.
Thanks for the new builder.
It would be great also to get a test-case for this builder.
docs/conf.py
Outdated
@@ -379,13 +379,14 @@ def custom_defined_func(): | |||
|
|||
# build needs.json to make permalinks work | |||
needs_build_json = True | |||
|
|||
# build needs per id | |||
needs_per_id = True |
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.
Why does the Sphinx-Needs doc configuration need this?
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.
I change commend: "build single need.json to make detail pannel". Is this ok?
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.
Will the detail pannel be part of Sphinx-Needs.
AFAIK it is not yet available, so we can activate this option when really needed.
Right now I don't see a use-case why this needs to be activated.
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.
Will I by pass this and needs-id folder always generated when build docs?
pytest tests/test_needs_id_builder.py => for run my test |
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.
Thanks for the changes and the test cases
Found only 2-3 minor things.
docs/configuration.rst
Outdated
Exports forder ``needs_per_id_build_path`` include all file ``needs.json`` for every needs-id. | ||
.. hint:: | ||
|
||
The created ``needs_id`` folder gets stored in the ``outdir`` of the current builder. The final location is e.g. _build/needs_id |
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.
e.g. _build/needs_id
-> Is needs_id
a builder here?
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.
e.g. _build/needs_id
-> Isneeds_id
a builder here?
This variable configs the folder name which is area generate all single file json for every needs-id
docs/configuration.rst
Outdated
|
||
needs_build_json_per_id | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
Builds a single ``needs.json`` file for every needs-id. |
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.
Will there be only one needs,json
file?
Do all the exports get the same file name?
Ohh and we need an entry for:
Please use also We also need an update for |
which rule setting version?I wonder how define it |
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.
Thanks for the update.
Some minor findings, which are all documentation related.
docs/configuration.rst
Outdated
This option works like needs_build_json. | ||
.. _needs_build_json_per_id: | ||
|
||
needs_build_json_per_id |
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.
Please document first needs_build_json_per_id
then needs_build_json_per_id_path
, as needs_build_json_per_id_path
is based on needs_build_json_per_id
The logic here is not reusing the https://github.com/useblocks/sphinx-needs/blob/master/sphinx_needs/needsfile.py I guess it would be enough to provide a different sphinx-needs/sphinx_needs/needsfile.py Lines 96 to 104 in 5b983a4
|
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.
Thanks for the changes, looks a little cleaner.
But I think 2 things we should change...
sphinx_needs/builder.py
Outdated
needs_list = NeedsList(config, self.outdir, self.srcdir) | ||
needs_list.wipe_version(version) | ||
needs_list.add_need(version, need) | ||
for need_filter in filters.values(): |
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.
I think adding the filters make no sense is in this case, as they would get repeated in each json file.
Just ignore them.
sphinx_needs/needsfile.py
Outdated
@@ -131,6 +131,21 @@ def load_json(self, file) -> None: | |||
|
|||
self.log.debug(f"needs.json file loaded: {file}") | |||
|
|||
def write_jsons(self, needs_file, needs_path) -> None: |
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.
If you have the loop for the needs outside the write_jsons
function, why can't you just use the existing write-json
?
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.
Looks good to me. Thanks for the changes 👍
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.
See comments
Heya @nhatnamnguyengtvthcm as you can see I'm making quite a few changes at the moment 😅 but I'll circle back round and have a look at these builder PRs soon cheers |
yeah. I see your comment and try to follow you |
about test cases.I removed all new folders and used the doc_needs_builder because the new builder has the same environment as needs needs-builder |
I see make test fail some case which was not changed from my side. Can you assist me in checking it @chrisjsewell ? |
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.
Some minor findings.
Maybe recheck also the provided docs. They are sometimes hard to understand.
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.
One last small finding :)
Rest looks 👍
LGTM. Contribution approved. |