In my docs/source/conf.py I have this code:
extensions = [
"sphinx.ext.autodoc",
"myst_parser",
]
source_suffix = ['.rst', '.md']
All my files are in Markdown, not in reStructuredText.
On ReadTheDocs, the initial build was successful technically, only until the modules page was "not found" and the index page is completely blank.
My .readthedocs.yaml:
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Optionally build your docs in additional formats such as PDF
formats: all
# Optionally set the version of Python and requirements required to build your docs
python:
version: "3.8"
install:
- method: pip
path: .
extra_requirements:
- docs
My setup.cfg contains this:
[options.extras_require]
docs =
sphinx
myst-parser
Of course, doing make clean html in docs/ works completely fine. Not sure why ReadTheDocs cannot properly link to the rest of the.md files from index.md.
I solved it. I checked the build logs, turns out I have some syntax errors (I did list[str] not List[str] with from typing import List)
Related
OH GEEZ
the extension is "myst**_**parser" and the library is myst-parser. The only thing better would be if somewhere else I had written mystParser...
Thank you
Steve - I don't use StackOverflow a lot. Is there something I need to do to recognize? that you provided the answer?
Add myst_parser to reqirements.txt. –
Steve Piercy
5 hours ago
sphinx-autobuild works great locally. I send my project to github with sphinx documentation (as .md files) within the /docs folder. Post to RTD web site. Fails. myst-parser is in requirements.txt.?
sphinx.errors.ExtensionError: Could not import extension myst_parser (exception: No module named 'myst_parser')
.readthedocs.yaml
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# 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"
# 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:
# - pdf
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
reqirements.txt
alabaster==0.7.12
Babel==2.11.0
bleach==5.0.1
build==0.9.0
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
colorama==0.4.6
commonmark==0.9.1
cryptography==38.0.4
docopt==0.6.2
docutils==0.17.1
idna==3.4
imagesize==1.4.1
importlib-metadata==5.1.0
influxdb==5.3.1
jaraco.classes==3.2.3
jeepney==0.8.0
Jinja2==3.1.2
keyring==23.11.0
livereload==2.6.3
markdown-it-py==2.1.0
MarkupSafe==2.1.1
mccabe==0.7.0
mdit-py-plugins==0.3.1
mdurl==0.1.2
more-itertools==9.0.0
msgpack==1.0.4
myst-parser==0.18.1
packaging==21.3
paho-mqtt==1.6.1
pep517==0.13.0
pipreqs==0.4.11
pkginfo==1.9.1
pycodestyle==2.10.0
pycparser==2.21
pyflakes==3.0.1
Pygments==2.13.0
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2022.6
PyYAML==6.0
readme-renderer==37.3
requests==2.28.1
requests-toolbelt==0.10.1
rfc3986==2.0.0
rich==12.6.0
SecretStorage==3.3.3
six==1.16.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinx-autobuild==2021.3.14
sphinx-rtd-theme==1.1.1
sphinx_design==0.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli==2.0.1
tornado==6.2
twine==4.0.1
typing_extensions==4.4.0
urllib3==1.26.13
webencodings==0.5.1
yarg==0.1.9
zipp==3.11.0
conf.py
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import os
import sys
# Add the code path
sys.path.insert(0, os.path.abspath('../code'))
project = 'GrowBuddies'
copyright = '2022, HappyDay'
author = 'HappyDay'
release = '2022.12.0'
# ignore files
exclude_patterns = ["py_env/*", '**/_*']
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = ['sphinx.ext.autodoc', 'myst-parser', 'sphinx.ext.autosectionlabel', 'sphinx_design']
# Make sure the target is unique
autosectionlabel_prefix_document = True
# Include methods that start with an _
napoleon_include_private_with_doc = True
# Add Myst extensions
myst_enable_extensions = ["colon_fence", "html_image"]
# Needed for font awesome support using the sphinx-design extension.
html_css_files = [
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
]
# Ignore documentating these files.
autodoc_mock_imports = ['influxdb', 'paho']
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
myst-parser is the name of the Python package. However, the name of the Python module once installed is myst_parser. You need to specify myst_parser in conf.py (not myst-parser).
My latest Sphinx documentaion fails when trying to build it with readthedocs. It has apperently something to do with the fact that I am trying to incorporate some badges from https://shields.io/. These badges are .svg graphic files.
I probably need to do some tweaking in my conf.py file?
On my local machine, I am able to produce the Sphinx documentation and all HTML files do look OK.
Here's an excerpt of my conf.py file:
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"nbsphinx",
"numpydoc",
"sphinx.ext.autodoc",
"sphinx_copybutton",
"sphinx.ext.napoleon",
]
napoleon_google_docstring = False
napoleon_numpy_docstring = True
numpy_validation_checks = {all}
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
Here's the text output: https://readthedocs.org/api/v2/build/17082650.txt
Although you may have disabled the epub and PDF builds in the RTD UI, you must take note in the RTD UI under Advanced Settings > Default settings:
These settings can be configured using a configuration file. That's the recommended way to set up your project. Settings listed here are ignored when using a configuration file.
Therefore you must be using a configuration file that enables both pdf and epub builds. Lo and behold:
https://github.com/andreas-vester/df2img/blame/3ba6e046c8d30ab3896b23835513740bd5aa97fa/.readthedocs.yaml#L12-L14
formats:
- pdf
- epub
I am using sphinx for building documentation in confluence.I am able to make html file using sphinx. But when I am trying to connect confluence using the "make confluence" command it's throwing an error
I checked by changing the confluence password and checked using API token still getting the error and unable to connect with confluence.
Ref link-
https://github.com/Shravankumarhiregoudar/sphinxDocumentation
conf.py file:
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.append('/home/4px/sphinx/scripts/')
# -- Project information -----------------------------------------------------
project = 'sites'
copyright = '2021, divyank'
author = 'divyank'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinxcontrib.confluencebuilder'
]
confluence_publish = True
confluence_space_name = 'Documentation'
##confluence_ask_password = True
#confluence_parent_name = 'API Documentation'
# (for Confluence Cloud)
confluence_server_url = 'https://<....>.atlassian.net/wiki/spaces'
confluence_server_user = '<....>'
confluence_server_pass = '<.......>'
# (or, for Confluence Server)
#confluence_server_url = 'https://intranet-wiki.example.com/'
#confluence_server_user = 'myawesomeuser'
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns=[]
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
'preamble': '',
# Latex figure (float) alignment
'figure_align': 'htbp',
}
Error:
WARNING: normalizing confluence url from https://<......>.atlassian.net/wiki/ to https://<.......>.atlassian.net/wiki/
sphinxcontrib.confluencebuilder error:
---
Unable to authenticate with the Confluence server.
Ensure your username and password are correct. If your username and password is correct, you may need to unlock your Confluence account be re-logging in with your browser or asking your Confluence administrator for help.
---
make: *** [confluence] Error 2
I am able to resolve this issue using API token in the confluence password field in conf.py file.
How to generate API token-
Manage API tokens for your Atlassian account
Ref link-
Unable to authenticate with the Confluence server using sphinxcontrib.confluencebuilder
There are so many posts describing this same error, and I have tried to read them all to find out exactly what is causing my error.
I have tried mangling this file eleven different ways, even reverting it back to the original file - still no luck. What am I missing?
The error is supposedly on "line 3 column 22" - which does not exist. I have no jekyll parser on the client side, everything is being handled through GitHub Pages.
https://github.com/drovani/drovani.github.io/commits/master/_config.yml
#
# This file contains configuration flags to customize your site
#
# Name of your site (displayed in the header)
name: "Rovani in C#"
# Short bio or description (displayed in the header)
description: "Ostinato, Pensato, Scordatura"
# URL of your avatar or profile pic (you could use your GitHub profile pic)
avatar: https://avatars3.githubusercontent.com/u/898478
#
# Flags below are optional
#
# Includes an icon in the footer for each username you enter
footer-links:
dribbble:
email: dev#rovani.net
facebook:
flickr:
github: drovani
instagram:
linkedin:
pinterest:
rss: # just type anything here for a working RSS icon
twitter: davidrovani
stackoverflow: "users/28310/drovani"
youtube: # channel/<your_long_string> or user/<user-name>
googleplus: # anything in your profile username that comes after plus.google.com/
# Enter your Disqus shortname (not your username) to enable commenting on posts
# You can find your shortname on the Settings page of your Disqus account
disqus: drovani
# Enter your Google Analytics web tracking code (e.g. UA-2110908-2) to activate tracking
google_analytics: UA-82341148-1
# Your website URL (e.g. http://barryclark.github.io or http://www.barryclark.co)
# Used for Sitemap.xml and your RSS feed
url:
# If you're hosting your site at a Project repository on GitHub pages
# (http://yourusername.github.io/repository-name)
# and NOT your User repository (http://yourusername.github.io)
# then add in the baseurl here, like this: "/repository-name"
baseurl: ""
#
# !! You don't need to change any of the configuration flags below !!
#
permalink: /:title/
# The release of Jekyll Now that you're using
version: v1.2.0
# Jekyll 3 now only supports Kramdown for Markdown
kramdown:
# Use GitHub flavored markdown, including triple backtick fenced code blocks
input: GFM
# Jekyll 3 and GitHub Pages now only support rouge for syntax highlighting
syntax_highlighter: rouge
syntax_highlighter_opts:
# Use existing pygments syntax highlighting css
css_class: 'highlight'
# Set the Sass partials directory, as we're using #imports
sass:
style: :expanded # You might prefer to minify using :compressed
# Use the following plug-ins
gems:
- jekyll-sitemap # Create a sitemap using the official Jekyll sitemap gem
- jekyll-feed # Create an Atom feed using the official Jekyll feed gem
# Exclude these files from your production _site
exclude:
- Gemfile
- Gemfile.lock
- LICENSE
- README.md
- CNAME
Instead of the issue being in the _config.yml file, it was in a completely different file altogether. So, if you get this error message from building a github-pages Jekyll page, don't assume that it is in the only "YAML" file. Search any new file that you have added for a Line 3 Column 22 and that will track down the error.
In my case, it was a title for a post in the front matter had a colon with a space after it - which I needed to put double-quotes around.
I have troubles creating a document directory (html) using sphinx-build.
I tried
sphinx-build -b html source build
as well as
make html
but in both cases only the html-files search.html, index.html and genindex.html are generated. The file modindex.html is missing.
In the file conf.py I set
html_domain_indices = True
so I should have a modindex.html file. What am I doing wrong? I get no error message after building the html files. I'm using Sphinx 1.1.3 and Python 2.7 on Windows XP.
Short version
run sphinx-apidoc -o . mymodule
uncomment and modify conf.py. For this example, sys.path.insert(0, os.path.abspath('mymodule'))
re-run make html
Long answer
I can reproduce the issue with this sample module:
$cat mymodule/mymodule.py
def fn1():
'''First function'''
pass
def fn2():
'''Second function'''
pass
Running sphinx-quickstart produces the following tree:
$tree
.
├── Makefile
├── _build
├── _static
├── _templates
├── conf.py
├── index.rst
├── mymodule
└── mymodule.py
$cat index.rst
.. sphinx example documentation master file, created by
sphinx-quickstart on Mon Mar 30 15:28:37 2015.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
with default index.rst:
Welcome to sphinx example's documentation!
==========================================
Contents:
.. toctree::
:maxdepth: 2
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Running make html at this point produces no output in _build/html/py-modindex.html. This is because sphinx needs .rst files describing every module. Fortunately it's easy to produce using sphinx-apidoc -o . mymodule.
This gives two new files, of which only mymodule.rst is necessary to fix the modindex issue in the question.
$head *mod*rst
==> modules.rst <==
mymodule
========
.. toctree::
:maxdepth: 4
mymodule
==> mymodule.rst <==
mymodule module
===============
.. automodule:: mymodule
:members:
:undoc-members:
:show-inheritance:
Running make html at this point still won't work. But uncommenting and changing the line beginning with sys.path.insert in conf.py fixes things.
Mine is: sys.path.insert(0, os.path.abspath('mymodule'))
PS: to avoid an additional warning, add modules to the Contents: toctree in the index.rst file.
The following is what I did for my project.
1. Install sphinx
pip install -U sphinx
2. Install theme (I've chosen sphinx_rtd_theme. Pleaser replace it with your choice)
pip install sphinx sphinx_rtd_theme
3. Create a doc directory under your project file
mkdir docs
4. Get into that directory
cd docs
5. Run sphinx-quickstart command
sphinx-quickstart
6. Run the following ( if you've enabled autodoc shpinx extension)
sphinx-apidoc -o source/ ../<modules_folder>
where source is the source folder used by sphinx and modules_folder is the folder your project's .py files-modules are in.
7. You will be prompted to reply to the questions below (change the answers according to your needs)
> Separate source and build directories (y/n) [n]: y
The project name will occur in several places in the built documentation.
> Project name: project_name
> Author name(s): your_nme
> Project release []: 1.01
> Project language [en]: en
8. It should look like the following if successfully run:
Creating file ...<***modules_folder***>/docs/source/conf.py.
Creating file ...<***modules_folder***>/docs/source/index.rst.
Creating file ...<***modules_folder***>/docs/Makefile.
Creating file ...<***modules_folder***>/docs/make.bat.
Finished: An initial directory structure has been created.
9. Edit conf.py and make sure the following lines are not commented (#):
import os # line 13
import sys # line 14
Note: .. stands for one directory up from doc directory
<modules_folder> is the folder your project's .py files-modules are in
sys.path.insert(0, os.path.abspath('../<modules_folder>/')) # line 16
make sure the following line exists
extensions = ['sphinx.ext.autodoc'] # line 34
change the theme if you'd like
html_theme = 'sphinx_rtd_theme' # line 51
10. Run shpinx-apidoc command
sphinx-apidoc -o . ..
Note:
. >> is for current directory
..>> is for one level up directory, i.e., the <modules_folder> project directory
11. Run make html command
.\make clean
.\make HTML
or
make clean
make html
12. Open your newely built webpage starting with
<modules_folder>/docs/build/html/index.html
Old question, but "working on the hard drive but not on ReadTheDocs" often has an easy fix.
Go to readthedocs
Navigate to your "Project Home"
Click 'Admin' then 'Advanced Settings'
Find and check the box for 'Install Project'
Return to 'Overview'
Build a new version
Check if it worked
Come back here and thank me