readthedocs / readthedocs.org

The source code that powers readthedocs.org
https://readthedocs.org/
MIT License
7.99k stars 3.58k forks source link

PDFs Not Generating in ReadTheDocs Flyer Menu #10861

Closed sachin-suresh-rapyuta closed 10 months ago

sachin-suresh-rapyuta commented 10 months ago

Details

Expected Result

After enabling the "Enable PDF build" checkbox in my Advanced Settings, PDFs are not being generated in the ReadTheDocs flyer menu.

Here is my .readthedocs.yml file which includes commands to build PDF from simple-pdf extension. Although the build succeeds executing all the commands, I cant see the PDF in flyer menu.

# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

#submodules:
#  include:
#    - paamr-deployment

# Set the version of Python and other tools you might need
build:
  os: ubuntu-20.04
  tools:
    python: "3.9"
    # You can also specify other tool versions:
    # nodejs: "16"
    # rust: "1.55"
    # golang: "1.17"
  #Add custom simple-pdf to readthedocs flyer menu
  commands:
    - pip install -r docs/requirements.txt
    - sphinx-build -b simplepdf docs .
    - mkdir -p _readthedocs/html/
    - sphinx-build -b html docs _readthedocs/html

# Build documentation in the docs/ directory with Sphinx
sphinx:
  configuration: docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
formats: all

# Optionally declare the Python requirements required to build your docs
python:
  install:
    - requirements: docs/requirements.txt

Actual Result

Just like HTML, even PDFs (including custom) should be build on every PR build.

humitos commented 10 months ago

Where does this command outputs the PDF files? sphinx-build -b simplepdf docs .

Take into account that you have to output your PDF files under $READTHEDOCS_OUTPUT/pdf. Read the docs about this at https://docs.readthedocs.io/en/latest/build-customization.html

sachin-suresh-rapyuta commented 10 months ago

Here is the updated commands:

commands:
    - pip install -r docs/requirements.txt
    - make clean
    - sphinx-build -b simplepdf docs $READTHEDOCS_OUTPUT/simplepdf/
    - mkdir -p $READTHEDOCS_OUTPUT/html/
    - sphinx-build -b html docs $READTHEDOCS_OUTPUT/html/

The build passes, but there is no option to download the PDF in the flyer menu. I have also created a tag (1.2.4) for this commit and activated the tag in readthedocs.

image

Is there any other setting that I need to do to see/test the PDF before merging the code?

humitos commented 10 months ago

You are outputting the result of that command under $READTHEDOCS_OUTPUT/simplepdf/ instead of $READTHEDOCS_OUTPUT/pdf/

sphinx-build -b simplepdf docs $READTHEDOCS_OUTPUT/simplepdf/

Also, note that there should be one and one PDF file under that directory and it should be named $READTHEDOCS_PROJECT.pdf. So, I would suggest you to adapt your code to be:

sphinx-build -b simplepdf docs /tmp/simplepdf/
mkdir -p $READTHEDOCS/pdf/
mv /tmp/simplepdf/<your generated PDF filename>.pdf $READTHEDOCS_OUTPUT/pdf/$READTHEDOCS_PROJECT.pdf

I hope that helps.

sachin-suresh-rapyuta commented 10 months ago

Based on the document version, my PDF file name is dynamically generated. So, to adapt this, I have modified my code below as:

commands:
    - pip install -r docs/requirements.txt
    - mkdir -p /tmp/simplepdf/  # Ensure the /tmp/simplepdf/ folder exists
    - rm -f /tmp/simplepdf/*.pdf  # Remove any existing PDF files in /tmp/simplepdf/
    - mkdir -p $READTHEDOCS/pdf/  # Ensure the destination directory exists
    - sphinx-build -b simplepdf docs /tmp/simplepdf/
    - mkdir -p $READTHEDOCS/pdf/
    - mkdir -p $READTHEDOCS_OUTPUT/html/
    - sphinx-build -b html docs $READTHEDOCS_OUTPUT/html/
    - mv /tmp/simplepdf/*.pdf $READTHEDOCS_OUTPUT/pdf/$READTHEDOCS_PROJECT.pdf

This is the error I see in readthedocs build for the last mv command:

mv: cannot move '/tmp/simplepdf/Rapyuta PA-AMR User Guide_en_3.1.pdf' to '/home/docs/checkouts/readthedocs.org/user_builds/io-amr-rr-pa-amr/checkouts/448/_readthedocs//pdf/io-amr-rr-pa-amr.pdf': No such file or directory

sachin-suresh-rapyuta commented 10 months ago

Here is another try where I gave the paths statically:

commands:
    - pip install -r docs/requirements.txt
    - mkdir -p /tmp/simplepdf/
    - rm -f /tmp/simplepdf/*.pdf
    - sphinx-build -b simplepdf docs /tmp/simplepdf/
    - mkdir -p /home/docs/checkouts/readthedocs.org/user_builds/io-amr-rr-pa-amr/checkouts/448/_readthedocs/pdf/
    - mkdir -p $READTHEDOCS_OUTPUT/html/
    - sphinx-build -b html docs $READTHEDOCS_OUTPUT/html/
    - mv /tmp/simplepdf/*.pdf /home/docs/checkouts/readthedocs.org/user_builds/io-amr-rr-pa-amr/checkouts/448/_readthedocs/pdf/io-amr-rr-pa-amr.pdf

Here, the build passes, and also I see Downloads>PDF option in the build output image

But, PDF is inaccessible in the Downloads directory.

https://io-amr-rr-pa-amr.readthedocs-hosted.com/_/downloads/en/448/pdf/

image

humitos commented 10 months ago

Hi @sachin-suresh-rapyuta! We have an open conversation in our support system. Please, let's continue talking there. I'm closing this issue since it's related to Read the Docs for Business.

sachin-suresh-rapyuta commented 10 months ago

@humitos - Can you please point me to the link of the open conversation that is happening about this?

humitos commented 10 months ago

@sachin-suresh-rapyuta you should have an email in your inbox from support@readthedocs.com where we have been talking about this already.

sachin-suresh-rapyuta commented 10 months ago

@sachin-suresh-rapyuta you should have an email in your inbox from support@readthedocs.com where we have been talking about this already.

No, I haven't received any email regarding this conversation.

humitos commented 10 months ago

Please contact us using https://readthedocs.com/support/ if you need help support related to Read the Docs for Business.

sachin-suresh-rapyuta commented 9 months ago

I still didn't get an answer to the previous query. Please help me with the email by forwarding it to me. It feels like the ticket was closed without any help or resolution. I just have the emails from support@readthedocs.com for the queries I have raised, but not for this issue @humitos

humitos commented 9 months ago

@sachin-suresh-rapyuta Please, contact us using readthedocs.com/support if you still need help with this issue on Read the Docs for Business. Thanks!