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

Allow to specify a part separator other than dot "." #1159

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

holmboe
Copy link
Contributor

@holmboe holmboe commented Mar 31, 2024

This (partly?) solves #1160.

With this patch you can refer to a need containing a dot, an example:

:need:`A5.1`

Before this patch:

Traceback (most recent call last):
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/cmd/build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/application.py", line 351, in build
    self.builder.build_all()
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 252, in build_all
    self.build(None, summary=__('all source files'), method='all')
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 363, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 299, in write
    doctree = self.assemble_doctree(
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 365, in assemble_doctree
    self.env.resolve_references(largetree, indexfile, self)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/environment/__init__.py", line 676, in resolve_references
    self.apply_post_transforms(doctree, fromdocname)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/environment/__init__.py", line 693, in apply_post_transforms
    self.events.emit('doctree-resolved', doctree, docname)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/events.py", line 97, in emit
    results.append(listener.handler(self.app, *args))
  File "/home/nn/code/github.com/holmboe/sphinx-needs/sphinx_needs/needs.py", line 350, in process_caller
    check_func(app, doctree, fromdocname, current_nodes[check_node])
  File "/home/nn/code/github.com/holmboe/sphinx-needs/sphinx_needs/roles/need_ref.py", line 95, in process_need_ref
    dict_need["title"] = target_need["parts"][need_id_part]["content"]
KeyError: '1'
> /home/nn/code/github.com/holmboe/sphinx-needs/sphinx_needs/roles/need_ref.py(95)process_need_ref()
-> dict_need["title"] = target_need["parts"][need_id_part]["content"]

holmboe and others added 2 commits March 31, 2024 10:24
With this patch you can refer to :need:`A5.1`.

Before this patch:

Traceback (most recent call last):
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/cmd/build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/application.py", line 351, in build
    self.builder.build_all()
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 252, in build_all
    self.build(None, summary=__('all source files'), method='all')
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 363, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 299, in write
    doctree = self.assemble_doctree(
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/builders/latex/__init__.py", line 365, in assemble_doctree
    self.env.resolve_references(largetree, indexfile, self)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/environment/__init__.py", line 676, in resolve_references
    self.apply_post_transforms(doctree, fromdocname)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/environment/__init__.py", line 693, in apply_post_transforms
    self.events.emit('doctree-resolved', doctree, docname)
  File "/home/nn/.local/pipx/venvs/sphinx/lib/python3.10/site-packages/sphinx/events.py", line 97, in emit
    results.append(listener.handler(self.app, *args))
  File "/home/nn/code/github.com/holmboe/sphinx-needs/sphinx_needs/needs.py", line 350, in process_caller
    check_func(app, doctree, fromdocname, current_nodes[check_node])
  File "/home/nn/code/github.com/holmboe/sphinx-needs/sphinx_needs/roles/need_ref.py", line 95, in process_need_ref
    dict_need["title"] = target_need["parts"][need_id_part]["content"]
KeyError: '1'
> /home/nn/code/github.com/holmboe/sphinx-needs/sphinx_needs/roles/need_ref.py(95)process_need_ref()
-> dict_need["title"] = target_need["parts"][need_id_part]["content"]
Copy link

codecov bot commented Mar 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.92%. Comparing base (0f71ecd) to head (f9d3c87).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1159   +/-   ##
=======================================
  Coverage   85.92%   85.92%           
=======================================
  Files          56       56           
  Lines        6536     6538    +2     
=======================================
+ Hits         5616     5618    +2     
  Misses        920      920           
Flag Coverage Δ
pytests 85.92% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@holmboe holmboe changed the title Allow to specify a part separator other than "." Allow to specify a part separator other than dot "." Apr 1, 2024
@holmboe
Copy link
Contributor Author

holmboe commented Apr 2, 2024

I have studied the code further and have identified a few more places where it would require changes for the config option needs_part_separator to have effect. Consider this PR a draft and place for discussion regarding a full implementation. It is likely that this PR will be closed and a new PR with full(er) support will take its place.

Thoughts?

@chrisjsewell
Copy link
Member

heya thanks, yeh I'm not against it in principle, but indeed would require a good look (and testing) to make sure it is working as expected 👍

@chrisjsewell chrisjsewell marked this pull request as draft April 2, 2024 12:23
@danwos
Copy link
Member

danwos commented Apr 2, 2024

I like the idea, but I'm afraid that this change is a tough one, as . as seperator is somehow hard-coded at a lot of places.

So the next step should be to have 2-3 additional test cases, which are changing the seperator and tests, if filtering, needflows and co. are all working.

@holmboe
Copy link
Contributor Author

holmboe commented Apr 3, 2024

Yes I can see that this is hard-coded in various places. I am motivated to dig through the code to find them out. However, I would be greatly helped if someone who is more intimately knowledgeable of the roles/directives/whatnot could create some test cases that is marked xfail. Any chance of this? @danwos @chrisjsewell

@holmboe
Copy link
Contributor Author

holmboe commented Jun 20, 2024

Note to self: this is likely helped by and related to split_need_id() merged in #1101.

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

3 participants