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

Make complex setting values like latex_documents overridable #12438

Open
terrorfisch opened this issue Jun 18, 2024 · 2 comments
Open

Make complex setting values like latex_documents overridable #12438

terrorfisch opened this issue Jun 18, 2024 · 2 comments
Labels
api:cmdline type:proposal a feature suggestion

Comments

@terrorfisch
Copy link

Is your feature request related to a problem? Please describe.
I want to override latex specific settings when invoking sphinx-build to embed the generated latex in an external document. I do not want to edit the original conf.py. First I tried a dedidcated conf.py but ran into problems with relative paths so I decided to try the command line settings override.

The --define documentation nicely explains how to override dict and list type values. However, latex_documents is a list of tuples which are not handled correctly.

Describe the solution you'd like
I do not have a favourite solution.

My original problem of patching "conf.py" without file modification can also be solved by additional "appendable" python code.

Describe alternatives you've considered

  • Make list entries addressable by <name>.<index> notation
  • Intoduce dedicated syntax for latex_document entry that does not use ,
  • Add a dedicated --json-settings argument which accepts a JSON object. This can be tricky to use because shells treat quotes differently.

Additional context
Parsing of list type values (btw: There is no way to escape the ","):

elif isinstance(default, list):

Interpretation of list elements as sequence in the latex builder:

preliminary_document_data = [list(x) for x in self.config.latex_documents]

@terrorfisch terrorfisch added the type:proposal a feature suggestion label Jun 18, 2024
@mgeier
Copy link
Contributor

mgeier commented Jun 19, 2024

First I tried a dedidcated conf.py but ran into problems with relative paths

I know this is fiddly, but I made it work in one instance like this: https://github.com/mgeier/diss/blob/3c5dcb7312b5132efccc4cbc7a55facf654f7c58/sphinx-splines/conf.py#L7-L8
Maybe that helps?

@terrorfisch
Copy link
Author

terrorfisch commented Jun 20, 2024

Thank you very much! That looks like it fits my usecase and solves some other problems I have been finding worse solutions for.

EDIT: I had to extend it by

for idx, html_path in enumerate(html_static_path):
    html_path = pathlib.Path(html_path)
    if not html_path.is_absolute():
        html_path = (original_conf_py.parent / html_path).resolve()
        html_static_path[idx] = str(html_path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:cmdline type:proposal a feature suggestion
Projects
None yet
Development

No branches or pull requests

3 participants