question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mkdocs: READTHEDOCS environment variables are null on mkdocs.yml

See original GitHub issue

Details

Our project is using:

Expected Result

  1. The cat mkdocs.yml build step should show proper values for env vars READTHEDOCS, READTHEDOCS_VERSION, and READTHEDOCS_PROJECT.

  2. A test html file with these contents:

    console.log("config.extra: {{ config.extra }}");
    console.log("config.extra.READTHEDOCS: {{ config.extra.READTHEDOCS }}");
    console.log("config.extra.READTHEDOCS_VERSION: {{ config.extra.READTHEDOCS_VERSION }}");
    

    should print something similar to this in the browser console:

    config.extra: {'READTHEDOCS': True, 'READTHEDOCS_VERSION': 1.2.3, 'READTHEDOCS_PROJECT': openvidu}
    config.extra.READTHEDOCS: True
    config.extra.READTHEDOCS_VERSION: 1.2.3
    

Actual Result

  1. The cat mkdocs.yml build step shows that READTHEDOCS, READTHEDOCS_VERSION, and READTHEDOCS_PROJECT are all null:

    extra:
      READTHEDOCS: null
      READTHEDOCS_PROJECT: null
      READTHEDOCS_VERSION: null
    
  2. The browser console shows this output:

    config.extra: {'READTHEDOCS': None, 'READTHEDOCS_PROJECT': None, 'READTHEDOCS_VERSION': None}
    config.extra.READTHEDOCS: None
    config.extra.READTHEDOCS_VERSION: None
    

Extra

Question / potential extra bug in the documentation: the technique shown in How do I change behavior when building with Read the Docs? would not really work with MkDocs, would it?

The sample is:

{% if READTHEDOCS %}
Woo
{% endif %}

but in MkDocs the READTHEDOCS is not directly available, is it expected to be? (sorry to ask here but is just a yes/no question that seems very relevant given the topic of the issue)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
j1elocommented, Mar 4, 2022

Hi,

It seems this is the only actionable item from this issue for now.

I guess an additional one was suggested from these sentences, but was never stated as a proper actionable item:

Which I’d take to become either of:

  • !ENV syntax support addition.
  • Workaround provided for usage of such syntax.
  • Decision taken about whether the “may” is to become a “will” in the phrase may be solved by our “Future builders” (this sounds to me like the best option, if those Future builders are actually going to become a reality at some point)
  • Follow the trail of a “similar solution than for !!” and see if the same ideas can actually be applied.
2reactions
humitoscommented, Sep 28, 2021

Hi @j1elo! Thanks for replying. You have mentioned here some interesting points that have been in our discussions lately but we haven’t yet had the time to fix them.

Thank you for the feedback. So far I’ve been left with the only choice of loading the (otherwise undocumented!) script readthedocs-data.js

This is not documented on purpose because we don’t expect users to use this data as it may change without communication. I don’t think it has changed in years now. However, we can’t compromise ourselves on that.

This bring the next followup question, not sure if worth a separate bug report: why the RTD context injection is not working either?

All the pages under /development/design/ are documents that we used to discuss proposed features. Some of them were never implemented --as the Theme Context that you just found 😞 . We have discussed not exposing these pages to users or moving them to a different set of documentation because we have already faced the confusion you are experimenting.

Seems to me that the general state of MkDocs support in RTD is pretty weak, as soon as you try to do anything beyond the most basic use cases

Unfortunately, this is true. Due to security restrictions, there are advanced MkDocs configurations that we cannot support currently and we haven’t had the time to change our internal implementation to reduce those risks. For the !ENV case, we could use a similar solution than for !! in https://github.com/readthedocs/readthedocs.org/issues/7461

no problem with that, but I do believe that adding appropriate comments in some of these doc pages would save long hours of frustration to users (at least I know it would have for me…)

I’m sorry to read that. I hope we can clarify these limitations in our documentation. @astrojuanlu what do you think about mentioning that non-standard (or advanced) YAML usage is not supported currently?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - MkDocs
Guide to all available configuration settings. Introduction . Project settings are configured by default using a YAML configuration file in the project ......
Read more >
Configuration - MkDocs - Read the Docs
Guide to all available configuration settings. Introduction. Project settings are always configured by using a YAML configuration file in the project directory ...
Read more >
Read the Docs Documentation
If the value is null, Read the Docs will try to find a mkdocs.yml file in ... Read the Docs supports two types...
Read more >
MkDocs: using a variable to construct external URLs
MkDocs is using Markdown, and therefore there are no available off-the-shelf variables you could use. So instead, you need to use something ...
Read more >
Themes - 咕的gitbook
you would include the following settings in mkdocs.yml to use the custom theme directory: theme: name: null custom_dir: 'custom_theme/' !!! Note
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found