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

[Enhance] update building docs #2419

Merged
merged 6 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 47 additions & 45 deletions docs/en/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (c) OpenMMLab. All rights reserved.
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand All @@ -9,15 +10,12 @@
# 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 subprocess
import sys

import pytorch_sphinx_theme
from m2r import MdInclude
from recommonmark.transform import AutoStructify
from sphinx.builders.html import StandaloneHTMLBuilder

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

Expand All @@ -27,17 +25,12 @@
copyright = '2020-2023, OpenMMLab'
author = 'MMDetection3D Authors'

version_file = '../../mmdet3d/version.py'


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


# The full version, including alpha/beta/rc tags
release = get_version()
version_file = '../../mmdet3d/version.py'
with open(version_file) as f:
exec(compile(f.read(), version_file, 'exec'))
__version__ = locals()['__version__']
release = __version__

# -- General configuration ---------------------------------------------------

Expand All @@ -48,17 +41,24 @@ def get_version():
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'myst_parser',
'sphinx_markdown_tables',
'sphinx.ext.autosectionlabel',
'sphinx_copybutton',
'myst_parser',
'sphinx.ext.intersphinx',
'sphinx.ext.autodoc.typehints',
'sphinx.ext.autosummary',
'sphinx.ext.autosectionlabel',
'sphinx_tabs.tabs',
]
autodoc_typehints = 'description'
autodoc_mock_imports = ['mmcv._ext']
autosummary_generate = True # Turn on sphinx.ext.autosummary

autodoc_mock_imports = [
'matplotlib', 'nuscenes', 'PIL', 'pycocotools', 'pyquaternion',
'terminaltables', 'mmdet3d.version', 'mmdet3d.ops', 'mmcv.ops'
]
autosectionlabel_prefix_document = True
# Ignore >>> when copying code
copybutton_prompt_text = r'>>> |\.\.\. '
copybutton_prompt_is_regexp = True

myst_enable_extensions = ['colon_fence']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -87,9 +87,7 @@ def get_version():
# 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',
Expand All @@ -99,6 +97,14 @@ def get_version():
'name':
Xiangxu-0103 marked this conversation as resolved.
Show resolved Hide resolved
'Upstream',
'children': [
{
'name':
'MMEngine',
'url':
'https://github.com/open-mmlab/mmengine',
'description':
'Foundational library for training deep learning models'
},
{
'name': 'MMCV',
'url': 'https://github.com/open-mmlab/mmcv',
Expand All @@ -125,22 +131,28 @@ def get_version():
# 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 = ['css/readthedocs.css']

latex_documents = [
Xiangxu-0103 marked this conversation as resolved.
Show resolved Hide resolved
(master_doc, 'mmcv.tex', 'mmcv Documentation', 'MMCV Contributors',
'manual'),
html_css_files = [
'https://cdn.datatables.net/1.13.2/css/dataTables.bootstrap5.min.css',
'css/readthedocs.css'
]

# set priority when building html
StandaloneHTMLBuilder.supported_image_types = [
'image/svg+xml', 'image/gif', 'image/png', 'image/jpeg'
html_js_files = [
'https://cdn.datatables.net/1.13.2/js/jquery.dataTables.min.js',
'https://cdn.datatables.net/1.13.2/js/dataTables.bootstrap5.min.js',
'js/collapsed.js',
'js/table.js',
]
# Enable ::: for my_st
myst_enable_extensions = ['colon_fence']
myst_heading_anchors = 3

language = 'en'
myst_heading_anchors = 4

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/latest/', None),
'mmengine': ('https://mmengine.readthedocs.io/en/latest/', None),
'mmdetection': ('https://mmdetection.readthedocs.io/en/latest/', None),
}


def builder_inited_handler(app):
Expand All @@ -149,13 +161,3 @@ 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)
20 changes: 11 additions & 9 deletions docs/en/stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,36 @@

import numpy as np

url_prefix = 'https://github.com/open-mmlab/mmdetection3d/blob/master/'
url_prefix = 'https://github.com/open-mmlab/mmdetection3d/blob/main'

files = sorted(glob.glob('../configs/*/README.md'))
files = sorted(glob.glob('../../configs/*/README.md'))

stats = []
titles = []
num_ckpts = 0

for f in files:
url = osp.dirname(f.replace('../', url_prefix))
url = osp.dirname(f.replace('../../', url_prefix))

with open(f, 'r') as content_file:
content = content_file.read()

title = content.split('\n')[0].replace('#', '').strip()
title = content.split('\n')[0].replace('# ', '').strip()
ckpts = set(x.lower().strip()
for x in re.findall(r'https?://download.*\.pth', content)
if 'mmdetection3d' in x)
for x in re.findall(r'\[model\]\((https?.*)\)', content))

if len(ckpts) == 0:
continue

_papertype = [x for x in re.findall(r'<!-- \[([A-Z]+)\] -->', content)]
_papertype = [x for x in re.findall(r'\[([A-Z]+)\]', content)]
assert len(_papertype) > 0
papertype = _papertype[0]

paper = set([(papertype, title)])

titles.append(title)
num_ckpts += len(ckpts)

statsmsg = f"""
\t* [{papertype}] [{title}]({url}) ({len(ckpts)} ckpts)
"""
Expand All @@ -49,14 +50,15 @@
[f' - {t}: {c}' for t, c in zip(papertypes, papercounts)])

modelzoo = f"""
\n## Model Zoo Statistics
# Model Zoo Statistics

* Number of papers: {len(set(titles))}
{countstr}

* Number of checkpoints: {num_ckpts}

{msglist}
"""

with open('model_zoo.md', 'a') as f:
with open('modelzoo_statistics.md', 'w') as f:
f.write(modelzoo)
93 changes: 46 additions & 47 deletions docs/zh_cn/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (c) OpenMMLab. All rights reserved.
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand All @@ -9,15 +10,12 @@
# 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 subprocess
import sys

import pytorch_sphinx_theme
from m2r import MdInclude
from recommonmark.transform import AutoStructify
from sphinx.builders.html import StandaloneHTMLBuilder

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

Expand All @@ -27,17 +25,12 @@
copyright = '2020-2023, OpenMMLab'
author = 'MMDetection3D Authors'

version_file = '../../mmdet3d/version.py'


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


# The full version, including alpha/beta/rc tags
release = get_version()
version_file = '../../mmdet3d/version.py'
with open(version_file) as f:
exec(compile(f.read(), version_file, 'exec'))
__version__ = locals()['__version__']
release = __version__

# -- General configuration ---------------------------------------------------

Expand All @@ -48,17 +41,24 @@ def get_version():
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'myst_parser',
'sphinx_markdown_tables',
'sphinx.ext.autosectionlabel',
'sphinx_copybutton',
'myst_parser',
'sphinx.ext.intersphinx',
'sphinx.ext.autodoc.typehints',
'sphinx.ext.autosummary',
'sphinx.ext.autosectionlabel',
'sphinx_tabs.tabs',
]
autodoc_typehints = 'description'
autodoc_mock_imports = ['mmcv._ext']
autosummary_generate = True # Turn on sphinx.ext.autosummary

autodoc_mock_imports = [
'matplotlib', 'nuscenes', 'PIL', 'pycocotools', 'pyquaternion',
'terminaltables', 'mmdet3d.version', 'mmdet3d.ops', 'mmcv.ops'
]
autosectionlabel_prefix_document = True
# Ignore >>> when copying code
copybutton_prompt_text = r'>>> |\.\.\. '
copybutton_prompt_is_regexp = True

myst_enable_extensions = ['colon_fence']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -87,9 +87,7 @@ def get_version():
# 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',
Expand All @@ -99,6 +97,11 @@ def get_version():
'name':
'上游库',
'children': [
{
'name': 'MMEngine',
'url': 'https://github.com/open-mmlab/mmengine',
'description': '深度学习模型训练基础库'
},
{
'name': 'MMCV',
'url': 'https://github.com/open-mmlab/mmcv',
Expand All @@ -114,33 +117,39 @@ def get_version():
],
# Specify the language of shared menu
'menu_lang':
'cn',
'en'
}

language = 'zh_CN'
language = 'en'

master_doc = 'index'

# 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 = ['css/readthedocs.css']

latex_documents = [
(master_doc, 'mmcv.tex', 'mmcv Documentation', 'MMCV Contributors',
'manual'),
html_css_files = [
'https://cdn.datatables.net/1.13.2/css/dataTables.bootstrap5.min.css',
'css/readthedocs.css'
]

# set priority when building html
StandaloneHTMLBuilder.supported_image_types = [
'image/svg+xml', 'image/gif', 'image/png', 'image/jpeg'
html_js_files = [
'https://cdn.datatables.net/1.13.2/js/jquery.dataTables.min.js',
'https://cdn.datatables.net/1.13.2/js/dataTables.bootstrap5.min.js',
'js/collapsed.js',
'js/table.js',
]
# Enable ::: for my_st
myst_enable_extensions = ['colon_fence']
myst_heading_anchors = 3

language = 'zh_CN'
myst_heading_anchors = 4

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/zh_CN/latest/', None),
'mmengine': ('https://mmengine.readthedocs.io/zh_CN/latest/', None),
'mmdetection': ('https://mmdetection.readthedocs.io/zh_CN/latest/', None),
}


def builder_inited_handler(app):
Expand All @@ -149,13 +158,3 @@ 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)
Loading