Skip to content

Commit

Permalink
fix readthedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lupin1998 committed Jan 7, 2024
1 parent dd292a2 commit cfbcbff
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 76 deletions.
7 changes: 6 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.8"

formats:
- epub

python:
version: 3.8
install:
- requirements: requirements/docs.txt
- requirements: requirements/readthedocs.txt
18 changes: 18 additions & 0 deletions docs/en/_templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "layout.html" %}

{% block body %}

<h1>Page Not Found</h1>
<p>
The page you are looking for cannot be found.
</p>
<p>
If you just switched documentation versions, it is likely that the page you were on is moved. You can look for it in
the content table left, or go to <a href="{{ pathto(root_doc) }}">the homepage</a>.
</p>
<p>
If you cannot find documentation you want, please <a
href="https://github.com/open-mmlab/mmpretrain/issues/new/choose">open an issue</a> to tell us!
</p>

{% endblock %}
13 changes: 13 additions & 0 deletions docs/en/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}


{{ name | underline}}

.. autoclass:: {{ name }}
:members:

..
autogenerated from _templates/autosummary/class.rst
note it does not have :inherited-members:
14 changes: 14 additions & 0 deletions docs/en/_templates/callable.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}


{{ name | underline}}

.. autoclass:: {{ name }}
:members:
:special-members: __call__

..
autogenerated from _templates/callable.rst
note it does not have :inherited-members:
13 changes: 13 additions & 0 deletions docs/en/_templates/data_transform.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}


{{ name | underline}}

.. autoclass:: {{ name }}
:members: transform

..
autogenerated from _templates/callable.rst
note it does not have :inherited-members:
186 changes: 156 additions & 30 deletions docs/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,66 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import subprocess
import sys

import pytorch_sphinx_theme
from sphinx.builders.html import StandaloneHTMLBuilder

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../../'))

# -- Project information -----------------------------------------------------

project = 'OpenMixup'
copyright = '2021-2022, CAIRI'
copyright = '2021-2024, CAIRI'
author = 'CAIRI OpenMixup Authors'

# # The full version, including alpha/beta/rc tags
# version_file = '../../openmixup/version.py'
# The full version, including alpha/beta/rc tags
version_file = '../../openmixup/version.py'


# def get_version():
# with open(version_file, 'r') as f:
# exec(compile(f.read(), version_file, 'exec'))
# return locals()['__version__']
def get_version():
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__']


# release = get_version()
release = get_version()

# -- 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.napoleon', 'sphinx.ext.viewcode',
'sphinx_markdown_tables', 'sphinx_copybutton', 'myst_parser'
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'myst_parser',
'sphinx_copybutton',
'sphinx_tabs.tabs',
'notfound.extension',
'sphinxcontrib.jquery',
]

autodoc_mock_imports = ['json_tricks', 'openmixup.version']

# Ignore >>> when copying code
copybutton_prompt_text = r'>>> |\.\.\. '
copybutton_prompt_is_regexp = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}

language = 'en'

# The master toctree document.
root_doc = 'index'

# 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.
Expand All @@ -65,11 +82,18 @@
'.md': 'markdown',
}

# -- 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 = 'pytorch_sphinx_theme'
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# yapf: disable
html_theme_options = {
# The target url that the logo directs to. Unset to do nothing
'logo_url': 'https://openmixup.readthedocs.io/en/latest/',
Expand Down Expand Up @@ -108,25 +132,127 @@
]
},
],
# For shared menu: If your project is a part of OpenMMLab's project and
# you would like to append Docs and OpenMMLab section to the right
# of the menu, you can specify menu_lang to choose the language of
# shared contents. Available options are 'en' and 'cn'. Any other
# strings will fall back to 'en'.
'menu_lang': 'en'
# Specify the language of shared menu
'menu_lang': 'en',
# Disable the default edit on GitHub
'default_edit_on_github': False,
}
# yapf: enable

# 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']
html_css_files = [
'https://cdn.datatables.net/v/bs4/dt-1.12.1/datatables.min.css',
'css/readthedocs.css'
]
html_js_files = [
'https://cdn.datatables.net/v/bs4/dt-1.12.1/datatables.min.js',
'js/custom.js'
]

language = 'en'
# -- Options for HTMLHelp output ---------------------------------------------

html_static_path = ['_static']
html_css_files = ['css/readthedocs.css']
# Output file base name for HTML help builder.
htmlhelp_basename = 'openstldoc'

# -- Options for LaTeX output ------------------------------------------------

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': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(root_doc, 'openmixup.tex', 'OpenMixup Documentation', author, 'manual'),
]

# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(root_doc, 'openmixup', 'OpenMixup Documentation', author, 'openstl',
'CAIRI Supervised, Semi- and Self-Supervised Visual Representation Learning Toolbox and Benchmark.', 'Miscellaneous'),
]

# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']

# set priority when building html
StandaloneHTMLBuilder.supported_image_types = [
'image/svg+xml', 'image/gif', 'image/png', 'image/jpeg'
]

# -- Extension configuration -------------------------------------------------
# Ignore >>> when copying code
copybutton_prompt_text = r'>>> |\.\.\. '
copybutton_prompt_is_regexp = True

# Auto-generated header anchors
myst_heading_anchors = 3
# Enable "colon_fence" extension of myst.
myst_enable_extensions = ['colon_fence', 'dollarmath']

# Configuration for intersphinx
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable', None),
'torch': ('https://pytorch.org/docs/stable/', None),
'mmcv': ('https://mmcv.readthedocs.io/en/2.x/', None),
'transformers':
('https://huggingface.co/docs/transformers/main/en/', None),
}
napoleon_custom_sections = [
# Custom sections for data elements.
('Meta fields', 'params_style'),
('Data fields', 'params_style'),
]

# Disable docstring inheritance
autodoc_inherit_docstrings = False
# Mock some imports during generate API docs.
autodoc_mock_imports = []
# Disable displaying type annotations, these can be very verbose
autodoc_typehints = 'none'

# The not found page
notfound_template = '404.html'


def builder_inited_handler(app):
if subprocess.run(['./stat.py']).returncode != 0:
raise RuntimeError('Failed to run the script `stat.py`.')

# Enable ::: for my_st
myst_enable_extensions = ['colon_fence']
myst_heading_anchors = 4

master_doc = 'index'
def setup(app):
pass
# app.connect('builder-inited', builder_inited_handler)
35 changes: 0 additions & 35 deletions docs/en/make.bat

This file was deleted.

14 changes: 5 additions & 9 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
docutils==0.16.0
markdown>=3.4.0
myst_parser
-e git+https://github.com/Westlake-AI/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
recommonmark
sphinx==4.0.2
docutils==0.18.1
modelindex
myst-parser
git+https://github.com/Westlake-AI/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
sphinx==6.1.3
sphinx-copybutton
sphinx-notfound-page
sphinx_markdown_tables>=0.0.16
sphinx_rtd_theme==0.5.2
sphinx-tabs
sphinxcontrib-jquery
tabulate
urllib3==1.26.15
1 change: 0 additions & 1 deletion requirements/runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ numpy
opencv-python
packaging
pandas
terminaltables
scipy
scikit-learn
seaborn
Expand Down

0 comments on commit cfbcbff

Please sign in to comment.