executablebooks / sphinx-tabs

Tabbed views for Sphinx
https://sphinx-tabs.readthedocs.io
MIT License
263 stars 67 forks source link

KeyError: 'tabs_stack' #161

Closed barbaricyawps closed 2 years ago

barbaricyawps commented 2 years ago

Describe the bug

context Hi, Sphinx Tabs friends! I'm trying to convert my docs to use sphinx-tabs instead of sphinx-inline-tabs because I think your tabs are rendered in a slightly more user-friendly way.

FYI, I'm building Sphinx using nox and venv environments and that might possibly be a factor.

When I try to build my Sphinx docs with your extension (running version 3.3.1), I get a build error with a KeyError exit code (see error message below).

expectation The Sphinx docs build should succeed, not fail. I seem to be able to do this exact same process on a different doc set using the same tools, so I don't know why I only get this bug in this environment.

bug I get this error message when the Sphinx build fails:

Exception occurred:
  File "/my-directory/lib/python3.10/site-packages/sphinx_tabs/tabs.py", line 143, in run
    tabs_id = self.env.temp_data["tabs_stack"][-1]
KeyError: 'tabs_stack'
The full traceback has been saved in /tmp/sphinx-err-m8zbbkt6.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

problem This is a problem for people building Sphinx docs because the build fails. Basically this one error prevents me from building my entire doc set. I'm also not super great at parsing and reading Python yet, so I don't know how to troubleshoot it myself. I'll get there.

Is it maybe some sort of packaging dependency that is having an error or is it a code problem?

Reproduce the bug

I can provide the error log if you need!

List your environment

I use the latest Sphinx that builds my docs using nox inside of a virtual environment (venv).

welcome[bot] commented 2 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:

foster999 commented 2 years ago

Hi @barbaricyawps, please could you provide a link to your project docs or a minimal example in markdown/rst that causes the same error?

foster999 commented 2 years ago

Please also review the example usage in our documentation, as it differs from sphinx-in line-tabs. It's possible that you're not wrapping 'tab' directives in a '' tabs' directive.

barbaricyawps commented 2 years ago

Thanks so much for your reply! Here's the project that I'm hoping to switch from inline tabs to sphinx-tabs: https://gitlab.com/saltstack/open/docs/salt-install-guide

We use sphinx-tabs on another project: https://gitlab.com/saltstack/open/docs/salt-user-guide

Because of that repo, I definitely know I can get it to work with the correct syntax. I'll double-check my syntax, though!

foster999 commented 2 years ago

Sorry, both of those links are to the second project that uses sphinx-tabs.

If the syntax does appear to be correct, please can you point me to an example using sphinx-tabs that is failing to build?

barbaricyawps commented 2 years ago

First off, hey, you're amazingly responsive, so HUGE thank you for that! πŸ˜„

My apologies if the mistake is on my end, but I thought you wanted an example of both the old inline tabs and the sphinx tabs which are using the same tech stack. I thought I provided that, but just in case I didn't, let me try again...

Here's an example of a topic on the Salt Install Guide that I'm trying to convert over to sphinx-tabs. Definitely uses inline tabs as it currently exists on the repository:

Basically I can't convert this topic over because even when I scrub all the old inline-tabs content to convert it to the sphinx-tabs syntax, the build fails and pre-commit prevents me from pushing up changes to open a merge request. When I update this topic and remove all the other topics that use tabs as a test, the build still fails after I convert this topic over to the sphinx-tabs syntax. Part of the problem might be that both sphinx-tabs and inline-tabs are trying to register the "tab" keyword.

Here's the project (Salt User Guide, different doc set) where we do successfully use sphinx-tabs:

So yeah, I can't show my attempts to convert our Salt Install Guide to spihnx-tabs because it fails to build and fails our pre-commit checks. The traceback error is what I get.

I haven't had time to try again and make sure all the old inline tabs content is officially gone in my working branch, but I will when I have a moment.

foster999 commented 2 years ago

No worries 😊

Thanks for sharing the additional links! I'm afraid I can't really help without seeing an example of the sphinx-tabs rst that reproduces the error (don't worry about the rendered version). You could share:

  1. A link to your working branch, if you push it up to the remote on GitLab
  2. A GitHub Gist containing an example of the sphinx-tabs rst that is failing to build
  3. A pasted code block here, showing sphinx-tabs rst that is failing to build

Note that for 2 or 3 you'll need to ensure that specific example doesn't build on it's own (i.e. When building only that page, with all other pages deleted). In doing this, you'll probably find the troublesome rst anyways 😁

There is a handy guide on creating reproducible examples on stack. As it suggests, the most useful examples are those which either start from scratch to recreate the problem, or just show a small part of the project that demonstrates the problem.

I don't think this is related your issue, but just to note that the sphinx-tabs guidance in the last set of links above could be made more concise using the 'code-tab' directive instead of nesting 'code-block' inside of a standard 'tab'.

foster999 commented 2 years ago

I'm assuming that the syntax error was found here, so closing the issue for now. Please feel free to comment again if the issue remains and you'd like further help