jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
511 stars 45 forks source link

'mike deploy'does not honor the mkdocs extra #190

Closed zxkane closed 8 months ago

zxkane commented 8 months ago

Summary

I define some variables in extra to render the text and dynamic links. After deploying the versioning docs, the text and link are not properly rendered.

But, the mkdocs serve/build and mike serve can render the page properly.

Configuration and Logs

extract variables, for example,

https://github.com/zxkane/clickstream-analytics-on-aws/blob/56432b443ac003371e8425130511c0109a9fd649/docs/mkdocs.base.yml#L63C6-L63C6

Use the variable in a documentation page,

https://github.com/zxkane/clickstream-analytics-on-aws/blob/56432b443ac003371e8425130511c0109a9fd649/docs/en/solution-overview/index.md?plain=1#L1

The final rendered page via mike deploy,

image

https://kane.mx/clickstream-analytics-on-aws/en/1.1.x/solution-overview/

Steps to Reproduce

see above configuration

Expected Behavior

The mike deploy can correctly render the variables from the extract variables.

Additional Context

jimporter commented 8 months ago

I define some variables in extra to render the text and dynamic links. After deploying the versioning docs, the text and link are not properly rendered.

But, the mkdocs serve/build and mike serve can render the page properly.

I don't think that's possible. mike serve simply shows the results of your gh-pages branch, which is just the contents of mike deploy (for all the versions you're hosting). So if mike serve works, then that implies mike deploy worked too. In addition, when generating your docs, mike deploy calls mkdocs build to do all the work, so if the latter works, the former should too.

I tested this locally, and this works fine for me once I installed mkdocs-macros-plugin, which I see you're using. In fact, I've used that plugin for years with mike (albeit by defining the macros through a Python script) with no issues.

jimporter commented 8 months ago

I took a look at your GH Actions log and I think something in your Actions configuration is broken. For both the Build mkdocs[1] and Deploy doc steps, I'd expect to see some log messages from the mkdocs-macros-plugin, but I don't. For instance, when running locally, I see these log messages:

INFO    -  [macros] - Macros arguments: {'module_name': 'main',
           'modules': [], 'include_dir': '', 'include_yaml': [],
           'j2_block_start_string': '', 'j2_block_end_string': '',
           'j2_variable_start_string': '', 'j2_variable_end_string': '',
           'on_undefined': 'keep', 'on_error_fail': False, 'verbose': False}
INFO    -  [macros] - Extra variables (config file): ['foo']
INFO    -  [macros] - Extra filters (module): ['pretty']

I'm guessing that when you run mkdocs build locally on your machine, it works. Make sure that whatever versions you have locally are the same as what you have in your GH Actions runner.

[1] You don't actually need to call mkdocs build in your CI, since you're not doing anything with the results. mike doesn't care about them, and will internally call mkdocs build as needed.

zxkane commented 8 months ago

@jimporter Thanks for sharing how mike serve works. Yes, I reproduce the same issue only using mkdocs serve/build.

Finally, I discovered that specifying the configuration below was to blame. I'll report it to mkdocs-material.

plugins:
  - search:
      lang: en