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

avoid duplicate label warnings for .. include::'ed files #136

Merged
merged 6 commits into from
Dec 31, 2021

Conversation

clalancette
Copy link
Collaborator

Sphinx does not like it when a file that is later included
(via .. include directive) has the very same link label inside of
it. To avoid a Sphinx warning, skip link label generation for
the pageindex.

Signed-off-by: Chris Lalancette clalancette@openrobotics.org

@clalancette clalancette requested a review from hidmic December 22, 2021 15:43
Copy link
Collaborator

@hidmic hidmic left a comment

Choose a reason for hiding this comment

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

LGTM though a comment explaining why the special case is needed would be great.

@svenevs thoughts?

@clalancette
Copy link
Collaborator Author

LGTM though a comment explaining why the special case is needed would be great.

Good call, done in 21ff1af

@svenevs
Copy link
Owner

svenevs commented Dec 24, 2021

I'm in the process of re-tooling a new OS, but not having a link may present issues with the tree view links (when using rst lists). My impression is one of the tests cases for pages should produce the warning we are discussing here, I think it's better to stuff exhale_ in front of the node.link_name and keep the link_declaration as is.

node.link_name = "exhale_{kind}_{id}".format(kind=node.kind, id=unique_id)

"page" is in the SPECIAL_CASES above there, I don't see any reason why stuffing exhale_ in front of everything is a problem (e.g., before the if entirely), the main split there is for adjusting the generated file title. There's an issue on windows where you can end up generating filenames that are too long or something iirc. Going to be looking into this later this evening (I use spack to manage things, it takes a number of hours to get everything setup the way I want...).

@svenevs svenevs force-pushed the clalancette/fix-warning branch 2 times, most recently from 117a05a to 43ce3c1 Compare December 27, 2021 02:03
@svenevs svenevs changed the title Skip generating link label for the pageindex. @svenevs avoid duplicate label warnings for .. include::'ed files Dec 27, 2021
@svenevs
Copy link
Owner

svenevs commented Dec 27, 2021

Turned out to be a slightly different problem, uncovered by the duplicate label. The index page is the first one that is being included that had a label that was therefore being duplicated, good catch! I've pushed some revert commits (and rebased for the updated testing matrix) with the final commit being the proposed fix. Anything that is .. include::'ed should now have a suffix .rst.include, special-casing for node.refid == "indexpage" in the filename component. Please confirm this eradicates the warnings for you.

tox -e py -- -s -k test_hierarchies_primary_mainpage and add self.app.build() to testing/tests/cpp_nesting.py:CPPNestingPages:test_hierarchies_primary_mainpage. There's a lot of other warnings there, but on master it's the first warning that comes up.

If things are working as expected I'll squash this soon 🙃

@svenevs svenevs changed the title @svenevs avoid duplicate label warnings for .. include::'ed files avoid duplicate label warnings for .. include::'ed files Dec 27, 2021
clalancette and others added 6 commits December 29, 2021 23:49
Sphinx does not like it when a file that is later included
(via .. include directive) has the very same link label inside of
it.  To avoid a Sphinx warning, skip link label generation for
the pageindex.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This reverts commit 21ff1af.
Sphinx will process any generated `.rst` file independently of if
it is being included somewhere.  Generated files that are going to
be `.. include::`'ed are renamed to `.rst.include` to avoid sphinx
processing the file separately.
@svenevs svenevs force-pushed the clalancette/fix-warning branch from 5d37b53 to bdd8073 Compare December 30, 2021 04:49
@svenevs svenevs merged commit b40765c into master Dec 31, 2021
@svenevs
Copy link
Owner

svenevs commented Dec 31, 2021

Merging as resolved, the warning is gone for me. Can revisit in followup if it is still a problem, preventing sphinx from processing the documents twice independently (once for the document it is .. include::ed in and once for the document itself) should probably reduce number of warnings and/or increase compile times (e.g., not re-processing the toctree links twice for every file in the generated api). Probably insignificant savings though

@svenevs svenevs deleted the clalancette/fix-warning branch December 31, 2021 23:52
@IceflowRE
Copy link
Contributor

I have some questions about this.
For our project this is a breaking change.
We used those files directly in a toctree. Which is not possible anymore due to the .include suffix. Is it still possible to do this?

@svenevs
Copy link
Owner

svenevs commented Sep 6, 2022

Opened #176 to discuss, it should be easy to have our cake and eat it too 🙂

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.

4 participants