Skip to content
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

Merged
merged 91 commits into from Sep 6, 2023

Conversation

nhatnamnguyengtvthcm
Copy link
Contributor

  1. In the builder, I build one builder which is name build_needs_id_json to build Json file per need id
  2. Using command: make docs-html-fast to run.
  3. Finally, in the "_build" folder will be gen the "needs_id" folder include all file json of need id.

@danwos danwos self-requested a review August 4, 2023 13:39
Copy link
Member

@danwos danwos left a 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
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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?

docs/configuration.rst Outdated Show resolved Hide resolved
docs/configuration.rst Outdated Show resolved Hide resolved
docs/configuration.rst Outdated Show resolved Hide resolved
docs/configuration.rst Outdated Show resolved Hide resolved
sphinx_needs/builder.py Show resolved Hide resolved
sphinx_needs/builder.py Show resolved Hide resolved
sphinx_needs/builder.py Outdated Show resolved Hide resolved
@nhatnamnguyengtvthcm
Copy link
Contributor Author

Thanks for the new builder. It would be great also to get a test-case for this builder.

pytest tests/test_needs_id_builder.py => for run my test

Copy link
Member

@danwos danwos left a 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.

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
Copy link
Member

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?

Copy link
Contributor Author

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?

This variable configs the folder name which is area generate all single file json for every needs-id


needs_build_json_per_id
~~~~~~~~~~~~~~~~~~~~~~~
Builds a single ``needs.json`` file for every needs-id.
Copy link
Member

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?

docs/configuration.rst Show resolved Hide resolved
@danwos
Copy link
Member

danwos commented Aug 7, 2023

Ohh and we need an entry for:

  • changelog.rst, to document the change for the version
  • AUTHORS file, if you like.

Please use also versionadded directive in the conf-docs, so that a user knows when the new config-option/builder was added.

We also need an update for docs/build.rst, which is totally missing currently

@nhatnamnguyengtvthcm
Copy link
Contributor Author

nhatnamnguyengtvthcm commented Aug 8, 2023

Ohh and we need an entry for:

  • changelog.rst, to document the change for the version
  • AUTHORS file, if you like.

Please use also versionadded directive in the conf-docs, so that a user knows when the new config-option/builder was added.

We also need an update for docs/build.rst, which is totally missing currently

which rule setting version?I wonder how define it

Copy link
Member

@danwos danwos left a 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/builders.rst Outdated Show resolved Hide resolved
docs/conf.py Outdated Show resolved Hide resolved
This option works like needs_build_json.
.. _needs_build_json_per_id:

needs_build_json_per_id
Copy link
Member

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

@danwos
Copy link
Member

danwos commented Aug 24, 2023

The logic here is not reusing the Needsfile class, which contains some important handling and configuration.
We should update/extend Needsfile to provide a function to store the data in the needed format.
But data preparation shall be reused from it.

https://github.com/useblocks/sphinx-needs/blob/master/sphinx_needs/needsfile.py

I guess it would be enough to provide a different write_json() function with your already existing logic.
Maybe write_jsons?

def write_json(self, needs_file: str = "needs.json") -> None:
# We need to rewrite some data, because this kind of data gets overwritten during needs.json import.
self.needs_list["created"] = datetime.now().isoformat()
self.needs_list["current_version"] = self.current_version
self.needs_list["project"] = self.project
needs_json = json.dumps(self.needs_list, indent=4, sort_keys=True)
file = os.path.join(self.outdir, needs_file)

Copy link
Member

@danwos danwos left a 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...

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():
Copy link
Member

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.

@@ -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:
Copy link
Member

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?

Copy link
Member

@danwos danwos left a 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 👍

Copy link
Member

@chrisjsewell chrisjsewell left a comment

Choose a reason for hiding this comment

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

See comments

@chrisjsewell
Copy link
Member

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

@nhatnamnguyengtvthcm
Copy link
Contributor Author

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

@nhatnamnguyengtvthcm
Copy link
Contributor Author

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

@nhatnamnguyengtvthcm
Copy link
Contributor Author

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

I see make test fail some case which was not changed from my side. Can you assist me in checking it @chrisjsewell ?

Copy link
Member

@danwos danwos left a 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.

docs/conf.py Outdated Show resolved Hide resolved
docs/changelog.rst Outdated Show resolved Hide resolved
docs/configuration.rst Outdated Show resolved Hide resolved
docs/configuration.rst Outdated Show resolved Hide resolved
sphinx_needs/builder.py Outdated Show resolved Hide resolved
Copy link
Member

@danwos danwos left a 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 👍

docs/configuration.rst Show resolved Hide resolved
@danwos danwos merged commit 1fc6bde into useblocks:master Sep 6, 2023
11 of 12 checks passed
@r-o-b-e-r-t-o
Copy link
Contributor

LGTM. Contribution approved.

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.

None yet

8 participants