Skip to content

Conversation

@Yoshanuikabundi
Copy link

Hi!

Thank you for this extension, it was just what I needed. Unfortunately, it did not correctly order the chapters for the project I was working on, which has an unusual structure:

  .. toctree::
     :numbered:
     :maxdepth: 3
  
     introduction
  
  .. toctree::
     :maxdepth: 3
  
     application
     library
     theory
  
  .. toctree::
     :numbered:
     :maxdepth: 3
  
     zbibliography

application, library and theory then have numbered toctrees of their own. I wanted chapter numbers to start at 1. Introduction, work through the toctree in order, and end at 22. Bibliography. Instead I got alphabetical ordering by reference name. I think this is partly because env.tocs is alphabetically ordered, at least in Sphinx 4, but also because I have numbered toctrees in index surrounding other numbered toctrees in other files. Even a correctly ordered env.tocs wouldn't be able to correctly render this tree, as it is sorted on the file level.

I solved this by walking the entire toctree, starting at index, and recording each numbered node in the order encountered. Then I just iterate over that list to number the tree. This should be pretty robust!

I'm contributing this back to you with thanks and in the hopes that it's useful to you or someone else. If you'd like to merge it, I'd be happy to write a test to make sure the above bug doesn't recur!

@welcome
Copy link

welcome bot commented Jul 6, 2021

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out EBP's Code of Conduct and our Contributing Guide, as this will greatly help the review process.

Welcome to the EBP community! 🎉

@AakashGfude
Copy link
Member

Hey, @Yoshanuikabundi . Thank you so much for the improvement. Sorry, we took so long to see this PR. I will verify it next week and give feedback/merge.

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.

2 participants