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

Pass current envvars into Popen when triggering diagram generation #149

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

fizyk
Copy link
Contributor

@fizyk fizyk commented Sep 5, 2024

This allows the command to work in environments using tools like asdf to maintain ie node dependencies

Longer explanation:

So far I had an environment prepared within a docker image to generate documentation.
However recently I was testing the feasibility to move it out of the docker definition into an easier cache'able (on CI) regular environment definition. Meaning that instead of dockerfile, I'd have Pipfile and node-modules required at the project's documentation level.
Since I also produce the documentation for confluence, I needed to generate svg's.
And because I try to separate component's virtualenv's to be able to update dependencies independently (also if a component requires node) I started using asdf-vm for that.
In order for mermaid to generate svg files through sphinxcontrib-mermaid, I had to pass environment variables, otherwise I got errors that npx mmdc command was not found.
Passing environmental variables fixes that issue, and allows to get the diagrams generated, at least in the case of mermaid_cmd_shell=False setting. mermaid_cmd_shell=True triggers the npx mmdc command without any issue, however the diagrams are not generated at all.

I've tested this on mermaid's own documentation with conf.py settings like that:

mermaid_output_format = 'svg'
mermaid_cmd = "npx mmdc"
mermaid_params = ['-p', 'puppeteer-config.json']

    This allows the command to work in environments using tools like asdf to maintain ie node dependencies
@mgaitan mgaitan merged commit 8cbe93b into mgaitan:master Sep 5, 2024
20 of 21 checks passed
@fizyk fizyk deleted the pass_envs branch September 10, 2024 14:25
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