-
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
Merged
danwos
merged 91 commits into
useblocks:master
from
nhatnamnguyengtvthcm:Namnn/need-per-id-json
Sep 6, 2023
Merged
Changes from 14 commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
eb546d4
gen needs.json per needs.id and command some service git to bypass test
nhatnamnguyengtvthcm 600ad3f
update review 11/07
nhatnamnguyengtvthcm 0228b24
update review 11/07
nhatnamnguyengtvthcm 9a698b0
update conf
nhatnamnguyengtvthcm 3de0647
config variable for needs_id forder path
nhatnamnguyengtvthcm dbb52c0
update env config for needs per id
nhatnamnguyengtvthcm 01320d4
add configuration for needs per id~
nhatnamnguyengtvthcm 177d3e3
add configuration for needs per id~
nhatnamnguyengtvthcm efbe1fa
fix-ci-lint-err
nhatnamnguyengtvthcm 04f5019
fix-ci-lint-err
nhatnamnguyengtvthcm be61481
fix-ci-lint-err
nhatnamnguyengtvthcm 103cc2f
fix-ci-lint-err
nhatnamnguyengtvthcm 274842f
fix-ci-lint-err
nhatnamnguyengtvthcm 1c2af5b
fix-ci-lint-err
nhatnamnguyengtvthcm 9136af8
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 26a18b8
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm ac7c5fe
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 618e1b0
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 8802a04
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 55e0cd3
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 6462295
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm dbb9f3f
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 13c1ca7
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 86bcfef
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm f42e9d7
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm f0ec457
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 724a367
change version build
nhatnamnguyengtvthcm 7e5b7e4
change changelog file
nhatnamnguyengtvthcm 86e343a
Removed esbonio for IDE support
haiyangToAI 30cae4d
enable docker arm builds
cpolzer 41c0368
🔧 Add .nox to gitignore
chrisjsewell bb83ac1
Update pyproject.toml
chrisjsewell c3ff8b6
Update pyproject.toml
chrisjsewell 7ca8d6e
Update requirements.txt
chrisjsewell 7680146
Update api.rst
chrisjsewell e969347
Added config allow unsafe filter for filter_func (#949)
haiyangToAI 3935da6
🔧 Update pre-commit hooks (#956)
chrisjsewell e518929
Bump actions/checkout from 3.3.0 to 3.5.3
dependabot[bot] 8a500e6
needs: Remove some of the extra IDs in the output
tim-nordell-nimbelink 786db24
Added config option needs_report_dead_links (#937)
haiyangToAI 624fd84
Raises version to 1.3.0
danwos ee77802
👌 Performance: Memoize Inline Parser
chrisjsewell cbc7bc0
fix linting
chrisjsewell ceae80e
Add to changelog
chrisjsewell 4ee996e
Easier Sphinx-Needs docs builds
danwos b8fe439
Docker fix
danwos 1b79d17
Removing docker context: ci
danwos ab99745
gen needs.json per needs.id and command some service git to bypass test
nhatnamnguyengtvthcm b9a0f99
update conf
nhatnamnguyengtvthcm f868ffe
update env config for needs per id
nhatnamnguyengtvthcm 4985e9f
fix-ci-lint-err
nhatnamnguyengtvthcm 0c8e80f
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 18cbd4e
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 305ad77
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm d9a967d
change version build
nhatnamnguyengtvthcm a9edc4e
update change log
nhatnamnguyengtvthcm bd18a2b
change release version
nhatnamnguyengtvthcm 6d50c27
♻️ Change `NeedsBuilder` format to `needs`
chrisjsewell b6819f4
Update changelog.rst
chrisjsewell 588e4cf
gen needs.json per needs.id and command some service git to bypass test
nhatnamnguyengtvthcm 5c30c12
update review 11/07
nhatnamnguyengtvthcm 6fd7eba
fix-ci-lint-err
nhatnamnguyengtvthcm f85bb09
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm d474b40
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm aaf3869
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm 1a288e0
add test-case and fix some setting for need per id builder
nhatnamnguyengtvthcm d8013c9
change version build
nhatnamnguyengtvthcm 819e716
change changelog file
nhatnamnguyengtvthcm 7aac5d3
Raises version to 1.3.0
danwos 41609ff
Add to changelog
chrisjsewell 4d88520
Easier Sphinx-Needs docs builds
danwos 6f5e62e
update conf
nhatnamnguyengtvthcm 6ff9b71
change version build
nhatnamnguyengtvthcm d1c46ac
rebase and merge version 1.3.0
nhatnamnguyengtvthcm c2ef673
merge version 1.3.0
nhatnamnguyengtvthcm 5e8fc85
fix merge version 1.3.0
nhatnamnguyengtvthcm 71988c4
fix merge version 1.3.0
nhatnamnguyengtvthcm a0c771b
move kogic in needs id builder into needsfile
nhatnamnguyengtvthcm 4d06008
move kogic in needs id builder into needsfile
nhatnamnguyengtvthcm a5af64f
move kogic in needs id builder into needsfile
nhatnamnguyengtvthcm 9077dca
using doc_needs_builder for test needs_id builder
nhatnamnguyengtvthcm 025cfc5
mofify configuration.rst
nhatnamnguyengtvthcm dafb701
merge version 1.3.0
nhatnamnguyengtvthcm cf47fd4
change version needs_id builder
nhatnamnguyengtvthcm b84e4cc
fix test case for needs_id_builder
nhatnamnguyengtvthcm ef926b1
update version 1.3.0
nhatnamnguyengtvthcm 0ac8a56
update version 1.3.0
nhatnamnguyengtvthcm 3a10072
update version 1.3.0
nhatnamnguyengtvthcm 49e91cb
update version 1.3.0
nhatnamnguyengtvthcm 43689e5
refactor confiuration file and builder
nhatnamnguyengtvthcm ba544e7
add version 1.4.0 in needs_build_json_per_id_path configurations.rst
nhatnamnguyengtvthcm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import json | ||
import os | ||
from typing import Iterable, Optional, Set | ||
|
||
|
@@ -6,6 +7,7 @@ | |
from sphinx.application import Sphinx | ||
from sphinx.builders import Builder | ||
|
||
from sphinx_needs.filter_common import filter_needs | ||
from sphinx_needs.logging import get_logger | ||
from sphinx_needs.needsfile import NeedsList | ||
from sphinx_needs.utils import unwrap | ||
|
@@ -43,9 +45,6 @@ def finish(self) -> None: | |
# This is needed as needs could have been removed from documentation and if this is the case, | ||
# removed needs would stay in needs_list, if list gets not cleaned. | ||
needs_list.wipe_version(version) | ||
# | ||
from sphinx_needs.filter_common import filter_needs | ||
|
||
filter_string = self.app.config.needs_builder_filter | ||
filtered_needs = filter_needs(self.app, needs, filter_string) | ||
|
||
|
@@ -158,3 +157,69 @@ def build_needumls_pumls(app: Sphinx, _exception: Exception) -> None: | |
needs_builder.set_environment(env) | ||
|
||
needs_builder.finish() | ||
|
||
|
||
class NeedsIdBuilder(Builder): | ||
danwos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name = "needs_id" | ||
danwos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
format = "json" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
file_suffix = ".txt" | ||
links_suffix = None | ||
LIST_KEY_EXCLUSIONS_NEEDS = ["content_node"] | ||
|
||
def write_doc(self, docname: str, doctree: nodes.document) -> None: | ||
pass | ||
|
||
def finish(self) -> None: | ||
env = unwrap(self.env) | ||
needs = env.needs_all_needs.values() | ||
needs_per_id_build_path = self.app.config.needs_per_id_build_path | ||
filter_string = self.app.config.needs_builder_filter | ||
filtered_needs = filter_needs(self.app, needs, filter_string) | ||
needs_id_json_dir = os.path.join(self.outdir, needs_per_id_build_path) | ||
if not os.path.exists(needs_id_json_dir): | ||
os.mkdir(needs_id_json_dir) | ||
for need in filtered_needs: | ||
needs_id_dict = {} | ||
id = need["id"] | ||
needs_id_dict[id] = {key: need[key] for key in need if key not in self.LIST_KEY_EXCLUSIONS_NEEDS} | ||
try: | ||
fname = os.path.join(needs_id_json_dir, f"{id}.json") | ||
with open(fname, "w") as f: | ||
json.dump(needs_id_dict, f, indent=4) | ||
except Exception as e: | ||
danwos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
log.error(f"Error during writing json file: {e}_{id}") | ||
nhatnamnguyengtvthcm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
log.info("Needs_id successfully exported") | ||
|
||
def get_outdated_docs(self) -> Iterable[str]: | ||
return [] | ||
|
||
def prepare_writing(self, _docnames: Set[str]) -> None: | ||
pass | ||
|
||
def write_doc_serialized(self, _docname: str, _doctree: nodes.document) -> None: | ||
pass | ||
|
||
def cleanup(self) -> None: | ||
pass | ||
|
||
def get_target_uri(self, _docname: str, _typ: Optional[str] = None) -> str: | ||
return "" | ||
|
||
|
||
def build_needs_id_json(app: Sphinx, _exception: Exception) -> None: | ||
env = unwrap(app.env) | ||
|
||
if not env.config.needs_per_id: | ||
return | ||
|
||
# Do not create an additional needs_json for every needs_id, if builder is already "needs_id". | ||
if isinstance(app.builder, NeedsIdBuilder): | ||
return | ||
|
||
try: | ||
needs_id_builder = NeedsIdBuilder(app, env) | ||
except TypeError: | ||
needs_id_builder = NeedsIdBuilder(app) | ||
needs_id_builder.set_environment(env) | ||
|
||
needs_id_builder.finish() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?