Skip to content

Commit 2d02bbe

Browse files
authored
Build readthedoc (#701)
* change version limitation in mminstall.txt * change version limitation in mminstall.txt * add config files for readthedocs * chmod 774 docs/en/stat.py * change .readthedocs/yml * fix typo
1 parent 1a074e5 commit 2d02bbe

File tree

9 files changed

+261
-5
lines changed

9 files changed

+261
-5
lines changed

.readthedocs.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ python:
99
- requirements: requirements/docs.txt
1010
- requirements: requirements/runtime.txt
1111
- requirements: requirements/readthedocs.txt
12-
- requirements: requirements/mminstall.txt

docs/en/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/en/_static/css/readthedocs.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.header-logo {
2+
background-image: url("../image/mmtrack-logo.png");
3+
background-size: 145px 40px;
4+
height: 40px;
5+
width: 145px;
6+
}
30.2 KB
Loading

docs/en/conf.py

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Copyright (c) OpenMMLab. All rights reserved.
2+
# Configuration file for the Sphinx documentation builder.
3+
#
4+
# This file only contains a selection of the most common options. For a full
5+
# list see the documentation:
6+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
7+
8+
# -- Path setup --------------------------------------------------------------
9+
10+
# If extensions (or modules to document with autodoc) are in another directory,
11+
# add these directories to sys.path here. If the directory is relative to the
12+
# documentation root, use os.path.abspath to make it absolute, like shown here.
13+
#
14+
import os
15+
import subprocess
16+
import sys
17+
18+
import pytorch_sphinx_theme
19+
20+
sys.path.insert(0, os.path.abspath('../..'))
21+
22+
# -- Project information -----------------------------------------------------
23+
24+
project = 'MMTracking'
25+
copyright = '2018-2021, OpenMMLab'
26+
author = 'MMTracking Authors'
27+
version_file = '../../mmtrack/version.py'
28+
29+
30+
def get_version():
31+
with open(version_file, 'r') as f:
32+
exec(compile(f.read(), version_file, 'exec'))
33+
return locals()['__version__']
34+
35+
36+
# The full version, including alpha/beta/rc tags
37+
release = get_version()
38+
39+
# -- General configuration ---------------------------------------------------
40+
41+
# Add any Sphinx extension module names here, as strings. They can be
42+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
43+
# ones.
44+
extensions = [
45+
'sphinx.ext.autodoc',
46+
'sphinx.ext.napoleon',
47+
'sphinx.ext.viewcode',
48+
'recommonmark',
49+
'sphinx_markdown_tables',
50+
'sphinx_copybutton',
51+
]
52+
53+
autodoc_mock_imports = [
54+
'matplotlib', 'pycocotools', 'terminaltables', 'mmtrack.version',
55+
'seaborn', 'motmetrics', 'torchvision', 'pandas', 'scipy'
56+
]
57+
58+
# Add any paths that contain templates here, relative to this directory.
59+
templates_path = ['_templates']
60+
61+
# The suffix(es) of source filenames.
62+
# You can specify multiple suffix as a list of string:
63+
#
64+
source_suffix = {
65+
'.rst': 'restructuredtext',
66+
'.md': 'markdown',
67+
}
68+
69+
# The master toctree document.
70+
master_doc = 'index'
71+
72+
# List of patterns, relative to source directory, that match files and
73+
# directories to ignore when looking for source files.
74+
# This pattern also affects html_static_path and html_extra_path.
75+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
76+
77+
# -- Options for HTML output -------------------------------------------------
78+
79+
# The theme to use for HTML and HTML Help pages. See the documentation for
80+
# a list of builtin themes.
81+
#
82+
# html_theme = 'sphinx_rtd_theme'
83+
html_theme = 'pytorch_sphinx_theme'
84+
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]
85+
86+
# Theme options are theme-specific and customize the look and feel of a theme
87+
# further. For a list of options available for each theme, see the
88+
# documentation.
89+
#
90+
html_theme_options = {
91+
# 'logo_url': 'https://mmtracking.readthedocs.io/en/latest/',
92+
'menu': [
93+
{
94+
'name': 'GitHub',
95+
'url': 'https://github.com/open-mmlab/mmtracking'
96+
},
97+
{
98+
'name':
99+
'Upstream',
100+
'children': [
101+
{
102+
'name': 'MMCV',
103+
'url': 'https://github.com/open-mmlab/mmcv',
104+
},
105+
{
106+
'name': 'MMDetection',
107+
'url': 'https://github.com/open-mmlab/mmdetection',
108+
},
109+
]
110+
},
111+
],
112+
# Specify the language of shared menu
113+
'menu_lang':
114+
'en'
115+
}
116+
117+
# Add any paths that contain custom static files (such as style sheets) here,
118+
# relative to this directory. They are copied after the builtin static files,
119+
# so a file named "default.css" will overwrite the builtin "default.css".
120+
html_static_path = ['_static']
121+
html_css_files = ['css/readthedocs.css']
122+
123+
language = 'en'
124+
125+
# Enable ::: for my_st
126+
myst_enable_extensions = ['colon_fence']
127+
myst_heading_anchors = 3
128+
129+
130+
def builder_inited_handler(app):
131+
subprocess.run(['./stat.py'])
132+
133+
134+
def setup(app):
135+
app.connect('builder-inited', builder_inited_handler)

docs/en/make.bat

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/en/stat.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
# Copyright (c) OpenMMLab. All rights reserved.
3+
import functools as func
4+
import glob
5+
import os.path as osp
6+
import re
7+
8+
import numpy as np
9+
10+
url_prefix = 'https://github.com/open-mmlab/mmtracking/blob/master/'
11+
12+
files = sorted(glob.glob('../../configs/*/*/README.md'))
13+
14+
stats = []
15+
titles = []
16+
num_ckpts = 0
17+
18+
for f in files:
19+
url = osp.dirname(f.replace('../../', url_prefix))
20+
21+
with open(f, 'r') as content_file:
22+
content = content_file.read()
23+
24+
title = content.split('\n')[0].replace('#', '').strip()
25+
ckpts = set(x.lower().strip()
26+
for x in re.findall(r'https?://download.*\.pth', content)
27+
if 'mmtracking' in x)
28+
if len(ckpts) == 0:
29+
continue
30+
31+
_papertype = [x for x in re.findall(r'\s*\[([A-Z]*?)\]\s*', content)]
32+
assert len(_papertype) > 0
33+
papertype = _papertype[0]
34+
35+
paper = set([(papertype, title)])
36+
37+
titles.append(title)
38+
num_ckpts += len(ckpts)
39+
statsmsg = f"""
40+
\t* [{papertype}] [{title}]({url}) ({len(ckpts)} ckpts)
41+
"""
42+
stats.append((paper, ckpts, statsmsg))
43+
44+
allpapers = func.reduce(lambda a, b: a.union(b), [p for p, _, _ in stats])
45+
msglist = '\n'.join(x for _, _, x in stats)
46+
47+
papertypes, papercounts = np.unique([t for t, _ in allpapers],
48+
return_counts=True)
49+
countstr = '\n'.join(
50+
[f' - {t}: {c}' for t, c in zip(papertypes, papercounts)])
51+
52+
modelzoo = f"""
53+
# Model Zoo Statistics
54+
* Number of papers: {len(set(titles))}
55+
{countstr}
56+
* Number of checkpoints: {num_ckpts}
57+
{msglist}
58+
"""
59+
60+
with open('modelzoo_statistics.md', 'w') as f:
61+
f.write(modelzoo)

requirements/mminstall.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
mmcls>=1.0.0rc0, <1.0.0
1+
mmcls>=1.0.0rc0,<1.0.0
22
mmcv-full>=2.0.0rc0,<2.0.0
33
mmdet>=3.0.0rc0,<3.0.0

requirements/readthedocs.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
mmcls
2-
mmcv
3-
mmdet
1+
mmcls>=0.16.0,<1.0.0
2+
mmcv-full>=1.3.17,<1.7.0
3+
mmdet>=2.19.1,<3.0.0
44
torch
55
torchvision

0 commit comments

Comments
 (0)