sphinx-needs icon indicating copy to clipboard operation
sphinx-needs copied to clipboard

title_from_content option has no effect when set via needs_global_options

Open arwedus opened this issue 3 years ago • 2 comments

Example config file section:

# Forces the user to set an ID for each need, which gets defined.
needs_id_required = True

# For selected directives below, a title is mandatory.
# For convenience, if a requirement has an empty title / heading line,
# we add option title_from_content so that the first sentence from content is used as title when we leave a title empty
# For the directives below, we add a validator via TIM that checks if the title is non-empty.
needs_global_options = {
    "title_from_content": (True, 'type=="req-sw"')
}

# For all other directives, a title is optional
needs_title_optional = True

Example output:

sphinx_title_from_content_via_global_options

NOTE: I also get some warnings like this:


/home/.../projects/docs-as-code/sphinx-examples/breathe-example/index.rst:12: ERROR: Error in "req-sw" directive:
1 argument(s) required, 0 supplied.

.. req-sw::
    :title_from_content:
    :id: REQ_CAT_0001
    :status: agreed

    Cats shall make the sound "meow" upon request.

The requirement is in this case missing from the output.

arwedus avatar Apr 26 '23 12:04 arwedus

This is a bug, as the title-calculation happens directly during a need instantiation, which happens much earlier as setting the global_options.

Maybe we can call the function _get_full_title again, after title_from_content was set via global_options.

danwos avatar May 10 '23 16:05 danwos

@danwos: would it be possible to plan this for a sphinx-needs 1.4.x release? :)

arwedus avatar Oct 02 '23 07:10 arwedus