diff --git a/docs/_static/css/readthedocs.css b/docs/_static/css/readthedocs.css new file mode 100644 index 0000000000..9d5dec72d3 --- /dev/null +++ b/docs/_static/css/readthedocs.css @@ -0,0 +1,6 @@ +.header-logo { + background-image: url("../image/mmediting-logo.png"); + background-size: 142px 46px; + height: 46px; + width: 142px; +} diff --git a/docs/_static/image/mmediting-logo.png b/docs/_static/image/mmediting-logo.png new file mode 100644 index 0000000000..95b851a916 Binary files /dev/null and b/docs/_static/image/mmediting-logo.png differ diff --git a/docs/api.rst b/docs/api.rst index 191ad02732..de5d16d385 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,6 +1,3 @@ -API Reference -================= - mmedit.core -------------- .. automodule:: mmedit.core diff --git a/docs/conf.py b/docs/conf.py index 7d0e76cea6..ed9180e1a5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,10 @@ import subprocess import sys +import pytorch_sphinx_theme +from m2r import MdInclude +from recommonmark.transform import AutoStructify + sys.path.insert(0, os.path.abspath('..')) # -- Project information ----------------------------------------------------- @@ -29,8 +33,13 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.viewcode', - 'myst_parser', 'sphinx_markdown_tables' + 'sphinx.ext.autodoc', + 'sphinx.ext.napoleon', + 'sphinx.ext.viewcode', + 'sphinx_markdown_tables', + 'sphinx.ext.autosectionlabel', + 'sphinx_copybutton', + 'myst_parser', ] autodoc_mock_imports = [ @@ -43,6 +52,10 @@ '.md': 'markdown', } +# 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'] @@ -56,12 +69,95 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'sphinx_rtd_theme' +# html_theme = 'sphinx_rtd_theme' +html_theme = 'pytorch_sphinx_theme' +html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()] + +html_theme_options = { + # 'logo_url': 'https://mmocr.readthedocs.io/en/latest/', + 'menu': [ + { + 'name': 'GitHub', + 'url': 'https://github.com/open-mmlab/mmediting', + }, + { + 'name': + 'Projects', + 'children': [ + { + 'name': 'MMAction2', + 'url': 'https://github.com/open-mmlab/mmaction2', + }, + { + 'name': 'MMClassification', + 'url': 'https://github.com/open-mmlab/mmclassification', + }, + { + 'name': 'MMDetection', + 'url': 'https://github.com/open-mmlab/mmdetection', + }, + { + 'name': 'MMDetection3D', + 'url': 'https://github.com/open-mmlab/mmdetection3d', + }, + { + 'name': 'MMEditing', + 'url': 'https://github.com/open-mmlab/mmediting', + }, + { + 'name': 'MMGeneration', + 'url': 'https://github.com/open-mmlab/mmgeneration', + }, + { + 'name': 'MMOCR', + 'url': 'https://github.com/open-mmlab/mmocr', + }, + { + 'name': 'MMPose', + 'url': 'https://github.com/open-mmlab/mmpose', + }, + { + 'name': 'MMSegmentation', + 'url': 'https://github.com/open-mmlab/mmsegmentation', + }, + { + 'name': 'MMTracking', + 'url': 'https://github.com/open-mmlab/mmtracking', + }, + ] + }, + { + 'name': + 'OpenMMLab', + 'children': [ + { + 'name': 'Homepage', + 'url': 'https://openmmlab.com/' + }, + { + 'name': 'GitHub', + 'url': 'https://github.com/open-mmlab/' + }, + { + 'name': 'Twitter', + 'url': 'https://twitter.com/OpenMMLab' + }, + { + 'name': 'Zhihu', + 'url': 'https://zhihu.com/people/openmmlab' + }, + ] + }, + ] +} # 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 = [] +html_static_path = ['_static'] +html_css_files = ['css/readthedocs.css'] + +myst_enable_extensions = ['colon_fence'] language = 'en' @@ -76,3 +172,13 @@ def builder_inited_handler(app): def setup(app): app.connect('builder-inited', builder_inited_handler) + app.add_config_value('no_underscore_emphasis', False, 'env') + app.add_config_value('m2r_parse_relative_links', False, 'env') + app.add_config_value('m2r_anonymous_references', False, 'env') + app.add_config_value('m2r_disable_inline_math', False, 'env') + app.add_directive('mdinclude', MdInclude) + app.add_config_value('recommonmark_config', { + 'auto_toc_tree_section': 'Contents', + 'enable_eval_rst': True, + }, True) + app.add_transform(AutoStructify) diff --git a/requirements/docs.txt b/requirements/docs.txt index 15c30563b9..d2599bcaf3 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -1,6 +1,9 @@ docutils==0.16.0 +m2r +mmcls==0.10.0 myst_parser +-e git+https://github.com/open-mmlab/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme recommonmark sphinx==4.0.2 +sphinx-copybutton sphinx_markdown_tables -sphinx_rtd_theme==0.5.2 diff --git a/setup.cfg b/setup.cfg index d700167c1a..ba80c78dce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,6 +19,6 @@ line_length = 79 multi_line_output = 0 known_standard_library = pkg_resources,setuptools known_first_party = mmedit -known_third_party =PIL,cv2,lmdb,mmcv,numpy,onnx,onnxruntime,packaging,pymatting,pytest,requests,scipy,titlecase,torch,torchvision,ts +known_third_party =PIL,cv2,lmdb,m2r,mmcv,numpy,onnx,onnxruntime,packaging,pymatting,pytest,pytorch_sphinx_theme,recommonmark,requests,scipy,titlecase,torch,torchvision,ts no_lines_before = STDLIB,LOCALFOLDER default_section = THIRDPARTY