html refactor (#555)

This commit is contained in:
Liang Bowen
2022-03-31 11:36:56 +08:00
committed by GitHub
parent d1211148a7
commit 2c45efc398
133 changed files with 274 additions and 672 deletions

View File

@@ -16,12 +16,6 @@ import sys
sys.path.insert(0, os.path.abspath('..'))
def get_version():
with open('../version.txt') as f:
return f.read().strip()
# -- Project information -----------------------------------------------------
project = 'Colossal-AI'
@@ -29,7 +23,8 @@ copyright = f'{datetime.datetime.now().year}, HPC-AI Tech'
author = 'HPC-AI Technology Inc.'
# The full version, including alpha/beta/rc tags
release = get_version()
release = '0.0.1'
# -- General configuration ---------------------------------------------------
@@ -40,6 +35,7 @@ extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.linkcode',
'myst_parser',
]
@@ -51,7 +47,9 @@ autodoc_typehints = 'none'
# Enable overriding of function signatures in the first line of the docstring.
autodoc_docstring_signature = True
autodoc_default_options = {'member-order': 'bysource'}
autodoc_default_options = {
'member-order': 'bysource',
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -69,7 +67,7 @@ exclude_patterns = ['.build', 'Thumbs.db', '.DS_Store']
html_theme = 'sphinx_rtd_theme'
html_show_sourcelink = False
html_theme_options = {
'navigation_depth': 2,
'navigation_depth': 3,
}
html_context = {
@@ -90,3 +88,48 @@ html_css_files = [
# -- Extension configuration -------------------------------------------------
source_suffix = ['.rst', '.md', '.MD']
import inspect
import colossalai
def linkcode_resolve(domain, info):
"""
Determine the URL corresponding to Python object
"""
if domain != 'py':
return None
modname = info['module']
fullname = info['fullname']
submod = sys.modules.get(modname)
if submod is None:
return None
obj = submod
for part in fullname.split('.'):
try:
obj = getattr(obj, part)
except Exception:
return None
try:
fn = inspect.getsourcefile(obj)
except Exception:
fn = None
if not fn:
return None
try:
source, lineno = inspect.findsource(obj)
except Exception:
lineno = None
if lineno:
linespec = "#L%d" % (lineno + 1)
else:
linespec = ""
fn = os.path.relpath(fn, start=os.path.dirname(colossalai.__file__))
github = "https://github.com/hpcaitech/ColossalAI/blob/main/colossalai/{}{}"
return github.format(fn, linespec)