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

Code formatting works locally but not on ReadTheDocs.org #4072

Closed
amit1rrr opened this issue May 9, 2018 · 26 comments
Closed

Code formatting works locally but not on ReadTheDocs.org #4072

amit1rrr opened this issue May 9, 2018 · 26 comments
Labels
Support Support question

Comments

@amit1rrr
Copy link

amit1rrr commented May 9, 2018

Details

  • Read the Docs project URL: docs.nurtch.com
  • Build URL (if applicable):
  • Read the Docs username (if applicable): [email protected]

Expected Result

I am expecting python code snippets to be syntax highlighted on ReadTheDocs.org. It's working fine locally where I have readthedocs theme installed. I am using code block. Here is the snippet example inside .rst file:

   .. code-block:: python

      from rubix.aws.cloudwatch import plot_metric

      # Load balancer P90 latency with deployment time markers
      plot_metric(namespace='AWS/ELB',
            metric_name='Latency',
            dimensions={'LoadBalancerName': 'prod-xyz-lb'},
            markers=deployment_times,
            statistics='p90')

      # Maximum CPU Utilization across EC2 for a specific time period
      plot_metric(namespace='AWS/EC2',
            metric_name='CPUUtilization',
            start_time=datetime.datetime(2018, 04, 25),
            end_time=datetime.datetime(2018, 04, 26)
            statistics='Maximum')

Screenshots attached.

Local Build.
local_build_output

On my hosted domain
on-readthedocs-org

@ivankravets
Copy link

It seems duplicate of #4050

@amit1rrr
Copy link
Author

amit1rrr commented May 9, 2018

It seems duplicate of #4050

Yes, looks like the same issue. Workaround is to explicitly specify the version of sphinx_rtd_theme package sphinx_rtd_theme>=0.3.1

I don't have any requirements.txt in my repository. There is one scant reference to it in the docs:
http://docs.readthedocs.io/en/latest/faq.html?highlight=requirements.txt#my-project-isn-t-building-with-autodoc

Looks like I need to go to Advanced settings and enable build with virtualenv and specify the requirements.txt file there. My questions is: what are all dependencies of building RTD.

Should these be enough?
shawnbrown/datatest@66f8455

@amit1rrr
Copy link
Author

amit1rrr commented May 9, 2018

EDIT: This doesn't work. Not permanently at least. See my comment below.

My issue is resolved.

Steps for other folks:

  • Go to Advanced Settings and select this option: Install your project inside a virtualenv using setup.py install
  • Add requirements.txt file to the text box on Advanced settings (see screenshot)
  • Scroll down and select this option as well: Give the virtual environment access to the global site-packages dir. (see second screenshot)
  • Create requirements.txt file in your project root with only this line:
    sphinx_rtd_theme>=0.3.1
  • Commit the project and verify that the build succeeds on RTD.
  • Code should have syntax highlighting

Screenshots:

11

12

@RichardLitt
Copy link
Member

Thank you, @amit1rrr, for both logging and resolving your issue! Glad you got it fixed.

@ivankravets
Copy link

@RichardLitt I'm not sure that a thousand developers should do the same. I think it should be fixed on RTFD side.

@stsewd
Copy link
Member

stsewd commented May 9, 2018

@ivankravets yeah, we didn't update the package on rtd because of a previous bug on the 0.3 version of the theme. But now that is fixed.

@amit1rrr
Copy link
Author

amit1rrr commented May 13, 2018

After I followed those steps a couple of builds went fine and now I started seeing this error on RTD:
python: can't open file 'setup.py': [Errno 2] No such file or directory

screen shot 2018-05-14 at 1 20 36 am

And rightly so, because if we have selected to install a project inside virtual env with setup.py then we need to write our own setup.py :( I am not sure why it succeeded the first few times.

Now spending time writing a setup.py to get my original issue of code formatting working is not worth it. @stsewd since the theme issue is fixed can of you update the package on rtd?

@amit1rrr amit1rrr reopened this May 13, 2018
@amit1rrr
Copy link
Author

amit1rrr commented May 13, 2018

I just made an attempt at simple setup.py that worked.
https://github.com/amit1rrr/nurtch-docs/blob/master/setup.py

Everyone shouldn't have to do all this to get syntax highlighting working for code blocks. Seems like an essential feature for any documentation system is broken in RTD.

marcbonnici added a commit to marcbonnici/workload-automation that referenced this issue May 14, 2018
The default version of the readthedocs theme does not support code
highlighting correctly so manually specify a compatible version as per
readthedocs/readthedocs.org#4072
marcbonnici added a commit to marcbonnici/workload-automation that referenced this issue May 14, 2018
The default version of the readthedocs theme does not support code
highlighting correctly so manually specify a compatible version as per
readthedocs/readthedocs.org#4072
marcbonnici added a commit to marcbonnici/workload-automation that referenced this issue May 14, 2018
The default version of the readthedocs theme does not support code
highlighting correctly so manually specify a compatible version as per
readthedocs/readthedocs.org#4072
@stsewd
Copy link
Member

stsewd commented May 14, 2018

I can say that the Install project option isn't required for your project, you only need the requirements.txt file

@stsewd stsewd added the Support Support question label May 14, 2018
@amit1rrr
Copy link
Author

amit1rrr commented May 14, 2018

@stsewd I just tried deselecting the Install Project option and only keeping the requirements.txt and code formatting is gone. I enabledInstall Project option again but still no code formatting. I pushed an empty commit to trigger a build still no code formatting.

I am terrified at inconsistent result of RTD builds with same configuration and same code. We should have an ability to replicate RTD build steps locally.

@stsewd
Copy link
Member

stsewd commented May 14, 2018

That's weird, can you please try to wipe the environment before doing a build? You can do this on the Versions section.

@stsewd
Copy link
Member

stsewd commented May 14, 2018

Also, you can re-build your docs manually from the Builds section

@amit1rrr
Copy link
Author

amit1rrr commented May 14, 2018

Worked fine after wiping. I think the sphinx_rtd_theme package would have got cached or something. Shouldn't wipe be default step on internal RTD builds.

@stsewd
Copy link
Member

stsewd commented May 14, 2018

Yes and no, I mean, the wipe feature is for doing a clean installation, that would be a waste of resources for rtd doing it on each build. This step is almost no need it, just in exceptional cases like this one.

@amit1rrr
Copy link
Author

amit1rrr commented May 14, 2018

This step is almost no need it, just in exceptional cases like this one.

I'm not sure about that. I have had inconsistent results twice in my first 2 weeks with RTD (documented in this thread above). When there is nothing exceptional in my build/package/config.
If it's package caching issue then at least every build that specifies requirements.txt should have wipe option enabled.

setrofim pushed a commit to ARM-software/workload-automation that referenced this issue May 14, 2018
The default version of the readthedocs theme does not support code
highlighting correctly so manually specify a compatible version as per
readthedocs/readthedocs.org#4072
@stsewd
Copy link
Member

stsewd commented May 15, 2018

We can close this, as the original issue was solved. I think there is already a follow up by the rtd team to upgrade the theme on the rtd side.

@stsewd stsewd closed this as completed May 15, 2018
@ivankravets
Copy link

@stsewd I did “wipe” for docs.platformio.org and it still doesn’t work without a custom requirements.txt

Should it work without extra steps as in the previous years?

@stsewd
Copy link
Member

stsewd commented May 15, 2018

@ivankravets yes, you need a requirements file with the rtd_theme version that fixes the syntax.

@stsewd
Copy link
Member

stsewd commented May 15, 2018

And as mention, rtd only needs to upgrade the default version of the theme and then you wouldn't need a requirements file.

@ivankravets
Copy link

Do you have any ETA when you will have this fixed on your side?

@morenoh149
Copy link

the follow up issue should be shared here for those interested

@stsewd
Copy link
Member

stsewd commented May 15, 2018

@ivankravets @morenoh149 Please see this comment #4050 (comment)

@davidfischer
Copy link
Contributor

Do you have any ETA when you will have this fixed on your side?

Probably within a week. We generally don't limit ourselves with strict timelines.

@morenoh149
Copy link

that's odd, this issue and the one you shared say the issue is fixed. What would it take to get https://solidity.readthedocs.io/en/v0.4.23/solidity-by-example.html working? because the issue ethereum/solidity#4125 (comment) said to track this issue (this thread).

@davidfischer
Copy link
Contributor

I re-opened #4050 until #4096 is merged. I think that's for the best so people can find it.

As to what it takes to get this working now, you need to pin to sphinx_rtd_theme>=0.3.1. Both of the two threads discuss that.

jarvisschultz added a commit to MurpheyLab/trep that referenced this issue Sep 3, 2018
Several issues noticed in logs of builds on RTD with inclusion of files in the
tutorial.

Also noticed that the syntax highlighting on RTD seemed broken compared to a
local build. Fixed by adding a requirements.txt file. See following links for
more:
readthedocs/readthedocs.org#4050
readthedocs/readthedocs.org#4072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Support question
Projects
None yet
Development

No branches or pull requests

6 participants