Skip to content

[MRG] DOC Avoid missing reference warnings, instead displaying as <code>#12970

Closed
thomasjpfan wants to merge 10 commits intoscikit-learn:masterfrom
thomasjpfan:filter_any_warnings
Closed

[MRG] DOC Avoid missing reference warnings, instead displaying as <code>#12970
thomasjpfan wants to merge 10 commits intoscikit-learn:masterfrom
thomasjpfan:filter_any_warnings

Conversation

@thomasjpfan
Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan commented Jan 13, 2019

Reference Issues/PRs

Fixes #12802, See also #12535

What does this implement/fix? Explain your changes.

Maps references that are not found to a code block.

doc/conf.py Outdated
def filter_any_references(record):
msg = record.getMessage()
return ("'any' reference target not found:" not in msg and
"more than one target found for 'any' cross-reference" not in msg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you give examines of this second error from the logs please?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

scikit-learn/sklearn/compose/_column_transformer.py:docstring of 
sklearn.compose.make_column_transformer:15: 
WARNING: more than one target found for 'any' cross-reference 'fit': 
could be :std:term: or :py:meth: or :py:meth: ...

Looking at the html, this fit reference does not actually reference anything. I suspect we want this to reference to the glossary.

This PR was updated to remove the second error filter, given it is a valid error.

Copy link
Copy Markdown
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Tbh I've not yet checked the logs, but...

@jorisvandenbossche
Copy link
Copy Markdown
Member

I am actually not fully sure this is the best solution. You could also say that all those warnings are indicating an error in the docs and could be fixed?
As I mentioned in #12535, it is also an option to only use single backticks for something we actually want to link, and double backticks for code snippet like things (and I think most of the warnings here would fall in that last category). Because now if you have a code snippet / unlinkable term, you get a different rendering when you use single vs double backticks.

In any case, this will also hide actual errors like a typo in something that you expected to link to the glossary or API docs.

@jnothman
Copy link
Copy Markdown
Member

jnothman commented Jan 16, 2019 via email

@jorisvandenbossche
Copy link
Copy Markdown
Member

And the any default role is explicit designed to back off to code-style font in case of no target.

That's not fully the case. At least, it has a different "look" than normal code with double backticks. It is in bold (and to me looks like missing link, but that's probably because I know too much about sphinx :-)).
In any case, that means you now have to different ways of styling code within the same docstring.

@thomasjpfan
Copy link
Copy Markdown
Member Author

The best solution would be to go through the warnings and make sure we use single backticks to actually reference something. Double backticks would be used to highlight code (with the gray background) that does not reference something.

@thomasjpfan
Copy link
Copy Markdown
Member Author

I have began the process of reviewing the docs and only use single backticks if they are referencing something in #12992.

@jnothman
Copy link
Copy Markdown
Member

jnothman commented Jan 16, 2019 via email

@thomasjpfan
Copy link
Copy Markdown
Member Author

My preference would be to not have to say "double backticks"

This goal is reasonable.

For reference, the warning:

WARNING: more than one target found for 'any' cross-reference 'fit': 
could be :std:term: or :py:meth:

appears because fit can link to either the glossary or the class method. By default it goes to the glossary. This is a little strange to me.

@jnothman
Copy link
Copy Markdown
Member

jnothman commented Jan 17, 2019 via email

@thomasjpfan
Copy link
Copy Markdown
Member Author

It will always point to the glossary, because sphinx will choose the first reference it finds, which is :term: in this case. You can see this behavior at https://43293-843222-gh.circle-artifacts.com/0/doc/modules/generated/sklearn.impute.SimpleImputer.html#sklearn.impute.SimpleImputer, where there is a fit reference in the Notes section.

For reference, here is the sphinx code that does this: https://github.com/sphinx-doc/sphinx/blob/7ffd6ccee8b0c6316159c4295e2f44f8c57b90d6/sphinx/transforms/post_transforms/__init__.py#L136-L141

@thomasjpfan
Copy link
Copy Markdown
Member Author

#13000 should help resolve the issue with more than one target found warnings.

@thomasjpfan thomasjpfan changed the title [MRG] Filters out "'any' reference target not found" warnings [MRG] Maps references that are not found to a code block Jan 18, 2019
@thomasjpfan
Copy link
Copy Markdown
Member Author

The latest update changes the 'any' roles that does not have any references to appear like a normal inline code element. Consider this page generated by this PR, the probability=True has the any role without a reference and now looks like a normal inline code block. Currently on the same page generated by the master docs, it looks like a reference without a link.

@thomasjpfan thomasjpfan changed the title [MRG] Maps references that are not found to a code block [MRG] Maps references that are not found to a inline code element Jan 18, 2019
@thomasjpfan
Copy link
Copy Markdown
Member Author

In addition to removing the warnings, this PR essentially makes single backticks act like double backticks when a reference is not found.


def maps_any_missing_reference_to_code_block(app, env, node, contnode):
if node['reftype'] == 'any':
contnode['classes'] = []
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you explain (and perhaps add a comment) how this results in code-like styling? Thanks.

@jnothman jnothman changed the title [MRG] Maps references that are not found to a inline code element [MRG] DOC Avoid missing reference warnings, instead displaying as inline <code> Jan 21, 2019
@jnothman jnothman changed the title [MRG] DOC Avoid missing reference warnings, instead displaying as inline <code> [MRG] DOC Avoid missing reference warnings, instead displaying as <code> Jan 21, 2019
Copy link
Copy Markdown
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

I've re-titled the PR. I hope that's alright.

@thomasjpfan
Copy link
Copy Markdown
Member Author

I am closing this PR in favor of the solution in #13000.

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.

Fix 'any' doc build warnings

3 participants