mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-08 12:30:42 +00:00
html refactor (#555)
This commit is contained in:
61
docs/conf.py
61
docs/conf.py
@@ -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)
|
||||
|
Reference in New Issue
Block a user