executablebooks / sphinx-external-toc

A sphinx extension that allows the site-map to be defined in a single YAML file
https://sphinx-external-toc.readthedocs.io
MIT License
33 stars 18 forks source link

Global options key in `_toc.yml` not reflected in `external_site_map` json representation #38

Closed AakashGfude closed 3 years ago

AakashGfude commented 3 years ago

On reading the JSON representation of the external_site_map using:

site_map = app.config.external_site_map
json_rep = yaml.dump(site_map.as_json())

it was found that it does not have the information of global options key stored in it.

Example:

with the following toc representation:

format: jb-book
root: content/preface
options:
 numbered: True
chapters:
- file: content/ch1
  options:
   numbered: True
- file: content/ch2
  sections:
    - file: content/ch4
    - file: content/ch5

the corresponding JSON representation of external_site_map object was :

documents:
  content/ch1:
    docname: content/ch1
    subtrees: []
    title: null
  content/ch2:
    docname: content/ch2
    subtrees:
    - caption: null
      hidden: true
      items:
      - content/ch4
      - content/ch5
      maxdepth: -1
      numbered: false
      reversed: false
      titlesonly: true
    title: null
  content/ch4:
    docname: content/ch4
    subtrees: []
    title: null
  content/ch5:
    docname: content/ch5
    subtrees: []
    title: null
  content/preface:
    docname: content/preface
    subtrees:
    - caption: null
      hidden: true
      items:
      - content/ch1
      - content/ch2
      maxdepth: -1
      numbered: true
      reversed: false
      titlesonly: true
    title: null
file_format: jb-book
meta: {}
root: content/preface

As can be seen, the local options are being passed through, but the global one is not. Perhaps it should have been in meta key?

cc: @mmcky

welcome[bot] commented 3 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:

mmcky commented 3 years ago

@AakashGfude just checking re: sphinx internals. It looks like to top level toctree:

  content/preface:
    docname: content/preface
    subtrees:
    - caption: null
      hidden: true
      items:
      - content/ch1
      - content/ch2
      maxdepth: -1
      numbered: true
      reversed: false
      titlesonly: true
    title: null

does have numbered: true -- is it possible that sphinx inherits this down the line for sub-tocs during a transform phase?

AakashGfude commented 3 years ago

Thanks, @mmcky . looks like I was looking at the wrong spot for this variable to exist. I will close this issue. Regarding the transform phase question, will just verify it in the code, and let you know.

numbered: true in chapters is actually faulty. Which I used above. It is only respected at the subtree level.