-
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
✨ NEW: Add NeedsPerPageBuilder
#962
base: master
Are you sure you want to change the base?
✨ NEW: Add NeedsPerPageBuilder
#962
Conversation
* Added config allow unsafe filter for filter_func * Fixed review * Updated sphinx-immaterial to fix CI * Fix linkcheck anchor issue --------- Co-authored-by: Daniel Woste <[email protected]>
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v3.3.0...v3.5.3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
Inside the LaTeX generator, it looks for the attributes ids and refid for creating link targets. When a new layer with a <container> wrapper was added in commit e51fc1f, for an unknown reason this triggered these additional IDs to generate links within the LaTeX output. A test case has been added to ensure only one hyperref within LaTeX is encountered as well. (useblocks#808)
Co-authored-by: Daniel Woste <[email protected]>
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 finding, but overall the code looks okay.
However, with Needsfile
there is a generic Need-Builder class, which cares about setting everything up the right way.
And I think we should use this and just extend it by a function to store the data in a specific way.
https://github.com/useblocks/sphinx-needs/blob/master/sphinx_needs/needsfile.py
Your code doubles a lot of functions, like filtering, data preparation, and some magic configurations.
That's hard to maintain in the future.
What do you think, is updating Needsfile
possible?
|
||
|
||
Format with file name: configuration.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.
What does this syntax do?
Please build the docs and check for errors before submitting.
A make docs-html
is now enough, as I fixed the doc-build and made it much easier.
|
||
Format with file name: configuration.json | ||
++++++ | ||
.. code-block:: python |
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.
Can you move this to a json file and present it here via .. literalinclude::
?
Much easier to maintain.
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.
Maybe just remove this and use the testing snapshots.
The problem with having it "statically" in the documentation, is that it is prone to become out-of-date with the actual code
docs/configuration.rst
Outdated
|
||
Build list of ``json`` files that contain all found needs with the same ``docname``. The name of each file should match the ``docname``. | ||
|
||
This option works like needs_build_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.
Please use :ref:
to reference other documentation objects.
|
||
.. versionadded:: 1.4.0 | ||
|
||
This option sets the location of list of ``json`` files that contain all found needs with the same ``docname``. |
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.
Is this a folder or a file name?
Is it relative to the build
folder or to the documentation root?
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.
It is name of folder
|
||
This option sets the location of list of ``json`` files that contain all found needs with the same ``docname``. | ||
|
||
Default value: need_per_page |
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 highlight path information like need_per_page
.
Add also a /
if it is a folder
sphinx_needs/builder.py
Outdated
needs_per_page_dir = os.path.join(self.outdir, needs_per_page_build_path) | ||
needs_per_page_data = {} | ||
if not os.path.exists(needs_per_page_dir): | ||
os.mkdir(needs_per_page_dir) |
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.
This does not work, if there are multiple new folders in the path, e.g. needs/pages/examples/
.
Use instead:
https://docs.python.org/3/library/os.html#os.makedirs
os.mkdir(needs_per_page_dir) | ||
|
||
needs_per_page_data_key = [] | ||
for need in filtered_needs: |
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 more comments would be good, especially if you have such much code in a single function and haven't it broken down to some sub functions.
At least for
-loops with multiple lines should get a comment, so that you know in advance what the goal of the for loop is before reading all code line.
Something like sorting needs into docname-based dict
would be helpful.
sphinx_needs/builder.py
Outdated
format = "needs" | ||
file_suffix = ".txt" | ||
links_suffix = None | ||
LIST_KEY_EXCLUSIONS_NEEDS = ["content_node"] |
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.
This is not Builder specific and is shared information that each builder must follow.
So if we need to extend it, we must touch multiple locations. That's not good.
That's one of the reasons why a central ``Needsfile` class was created to deal with such common configs.
https://github.com/useblocks/sphinx-needs/blob/master/sphinx_needs/needsfile.py
I wonder do you want the format of the JSON file generated the same needs.json. should It generate by function in needsfile? |
@@ -361,6 +361,9 @@ def custom_defined_func(): | |||
# build needs.json to make permalinks work | |||
needs_build_json = True | |||
|
|||
# build json file include needs with the same docs_name | |||
needs_per_page = 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.
This option name should be consistent with the other builders (build_json
, build_json_per_id
), i.e. build_json_per_page
Thinking holistically, with there now being numerous data writers, and more on the way, maybe it makes sense to have some form of unified configuration option.
For example:
needs_data_writers = ["json", "json_per_id", "json_per_page"]
LGTM. Approved for contribution. |
2 . run: make-html-fast -> the need_per_page folder will be gened which has seperated the need with same docs_name