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

tab-set-code produces warning for code-block #79

Closed
tcmetzger opened this issue Jul 2, 2022 · 3 comments
Closed

tab-set-code produces warning for code-block #79

tcmetzger opened this issue Jul 2, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@tcmetzger
Copy link

Describe the bug

context
When I use .. code-block:: directives inside of .. tab-set-code::

expectation
I expected the docs to build without warning or error.

bug
But instead I get a warning when running make html: WARNING: All children of a 'tab-code-set' should be a 'literal_block' [design.tab_code]

$ make html

problem
This is a problem because according to the documentation, .. tab-set-code:: should work with .. code-block:: directives, and the (apparently unnecessary) warning is confusing.

Reproduce the bug

In a RST file, include the following:

.. tab-set-code::

    .. code-block:: sh

        cd sphinx

run make html

This gives me the aforementioned warning.

If instead I use:

.. tab-set-code::

    .. literalinclude:: ./snippet.py
        :language: python

I don't get the warning

List your environment

sphinx 5.0.2
pydata-sphinx-theme 0.9.0
sphinx-design 0.2.0
Python 3.10.5
Linux-5.13.0-52-generic-x86_64-with-glibc2.31

@tcmetzger tcmetzger added the bug Something isn't working label Jul 2, 2022
@welcome
Copy link

welcome bot commented Jul 2, 2022

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@bryevdv
Copy link

bryevdv commented Jul 2, 2022

It looks like this is the relevant check:

if not isinstance(item, nodes.literal_block):
LOGGER.warning(
f"All children of a 'tab-code-set' "
f"should be a 'literal_block' [{WARNING_TYPE}.tab_code]",
location=tab_set,
type=WARNING_TYPE,
subtype="tab_code",
)

However, the Sphinx CodeBlock directive actually returns a 1-element list with the literal_block inside:

https://github.com/sphinx-doc/sphinx/blob/b9736f23484b16feef86208ab00dd947c54446ba/sphinx/directives/code.py#L169

@tcmetzger
Copy link
Author

Seems like this was actually due to me using an incorrectly escaped character - I'm closing this issue as this seems to work correctly. Apologies!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants