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

Add object description options mechanism #75

Merged
merged 2 commits into from
Apr 28, 2022
Merged

Conversation

jbms
Copy link
Owner

@jbms jbms commented Apr 26, 2022

This replaces manny config options with a more general "object
description options" mechanism that allows various options to be
configured on a per domain/object type basis.

This commit also adds a number of features built on top of that mechanism:

  • Generating object description synopses for the std domain, including
    custom object types added using app.add_object_type.

  • Excluding certain object types from the TOC

  • Excluding the object type from the cross-reference tooltip.

Fixes #70.

@jbms jbms force-pushed the object-description-options branch from be5ccba to 4fcd782 Compare April 26, 2022 02:04
@jbms jbms requested a review from 2bndy5 April 26, 2022 02:04
docs/conf.py Show resolved Hide resolved
docs/conf.py Outdated
Comment on lines 173 to 175
html_wrap_signatures_with_css = ["py"]
object_description_options_patterns.append(
("py:.*", dict(wrap_signatures_with_css=True))
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just pushed the v0.5.0 tag without knowing your work on this was changing the config option names. These config option changes seem like a breaking change, so I'd use a major version bump for the next tag.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It is true that it is a breaking change, but on the other hand if we get this in soon I doubt too many people will have used the new options yet.

Also v0 generally means no stability guarantees.

But yeah it could make sense to increase to v1.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm ok with bumping minor version because I'd also consider v0 as "beta" state.

docs/api.rst Outdated Show resolved Hide resolved
docs/format_signatures.rst Outdated Show resolved Hide resolved
@jbms jbms force-pushed the object-description-options branch 3 times, most recently from b341983 to d312942 Compare April 26, 2022 03:22
docs/conf.py Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
docs/conf.py Outdated Show resolved Hide resolved
@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

Please hold. I'm having trouble getting the solution to #70 working. I'm trying

object_description_pattern = [
    ("cpp:functionParam", dict(include_in_toc=False, generate_synopses=None))
]

But it still shows param in the toc and synopses are the entire paragraph (albeit still incorrect because of #69 )

@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

Nevermind. I see the typo in the config option now. That also explains why the docs weren't rebuilding when I changed the typo'd option's setting.

All is good to go when you are.

@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

According to the docs you added, the object_description_options_map is a dict and object_description_options_patterns is a list. But all example snippets that use a list are assigned to object_description_options_map.

I'm starting to notice that this more generic approach (making the user specify a specific object type) is too generic as it requires intimate knowledge of sphinx inner workings (most of which aren't really documented like functionParam). Add regex into the mix, and you've got a pretty confusing user interface.

docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
@jbms
Copy link
Owner Author

jbms commented Apr 26, 2022

I will have to fix the doc issues. It could be nice to have a more powerful version of rst-example that lets us use modified conf.py but that might be tricky to implement.

Most of the time the object type matches the directive name so it should be fairly easy to understand. However it is true that the param types are hidden --- we would need to document them.

docs/api.rst Outdated Show resolved Hide resolved
@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

Originally, I had two rst-results type directives. Only the simpler form made it to PR. The other more complicated form was meant to take the first literal block designated as RST (via the node's language property) and output that rendered. What I wanted was to be able to feed it tabbed content and show the result below the tabbed content (despite which tab was active). But, it was harder to implement (trying to compensate for user error) and buggy (absent a closing html div tag).

Wouldn't using a modified conf.py for an example snippet require a independent (or possible divergent from primary) sphinx env object? That sounds a bit more than just "tricky". It would be great for tests/validation though.

@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

I could revisit the tabbed results idea and grab the first literal block with a caption title ending in "conf.py" (probably would use os.path for that). Then any code in the conf.py snippet would be temporarily augmented to the app.env.config (restoring the env would be the tricky part - interpreting string literals as python code would be the hard part). This is all subject to using code-block directive properly (via language and caption properties). I would still need to solve the missing </div> problem though (felt like I was going bald trying to resolve that).

@jbms
Copy link
Owner Author

jbms commented Apr 26, 2022

Yeah, using a modified conf.py would require running a separate sphinx build entirely (but presumably just for a single page) and then somehow incorporating the result into the main documentation. Probably would work best as a link to a separate page, or embedded as an iframe that is zoomed out perhaps.

This would be particularly nice for demonstrating the mkdocs-material features options.

@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

iframe idea might be more complicated since it uses a isolated DOM.

@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

I also can't seem to get include_object_description_fields_in_toc=False to work.

object_description_options_patterns = [
    ("cpp:.*", dict(include_object_description_fields_in_toc=False)),
]

@2bndy5
Copy link
Collaborator

2bndy5 commented Apr 26, 2022

It seems that option is actually named include_fields_in_toc now. ("cpp:.*", dict(include_fields_in_toc=False)) works.

docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
@jbms
Copy link
Owner Author

jbms commented Apr 28, 2022

It seems that option is actually named include_fields_in_toc now. ("cpp:.*", dict(include_fields_in_toc=False)) works.

Fixed.

@jbms jbms force-pushed the object-description-options branch 3 times, most recently from c55fb8b to 5634244 Compare April 28, 2022 03:37
@jbms jbms requested a review from 2bndy5 April 28, 2022 03:40
@jbms jbms force-pushed the object-description-options branch from 5634244 to 0079225 Compare April 28, 2022 04:15
jbms and others added 2 commits April 27, 2022 21:29
This replaces manny config options with a more general "object
description options" mechanism that allows various options to be
configured on a per domain/object type basis.

This commit also adds a number of features built on top of that mechanism:

- Generating object description synopses for the std domain, including
  custom object types added using `app.add_object_type`.

- Excluding certain object types from the TOC

- Excluding the object type from the cross-reference tooltip.

Fixes #70.

Co-authored-by: Brendan <[email protected]>
@jbms jbms force-pushed the object-description-options branch from 0079225 to fdea0c9 Compare April 28, 2022 04:29
Copy link
Collaborator

@2bndy5 2bndy5 left a comment

Choose a reason for hiding this comment

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

Testing looks good now. I can't find any other objections.

@jbms jbms merged commit 2356dda into main Apr 28, 2022
@jbms
Copy link
Owner Author

jbms commented Apr 28, 2022

Thanks for the very thorough review!

@jbms jbms deleted the object-description-options branch April 28, 2022 05:14
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.

add option to disable cross-linking C++ parameters
2 participants