Skip to content

Commit 64804e8

Browse files
committed
docs: Update documentation generation. Make it mor verbose.
1 parent ed7c44b commit 64804e8

3 files changed

Lines changed: 255 additions & 230 deletions

File tree

docs/Dockerfile.docs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2525
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626

27-
FROM ubuntu:22.04
27+
FROM ubuntu:24.04
2828

2929
# various documentation dependencies
3030
RUN apt-get update -q=2 \
@@ -53,6 +53,7 @@ RUN wget https://github.com/pseudomuto/protoc-gen-doc/releases/download/v1.3.2/p
5353
&& rm /tmp/protoc-gen-doc.tar.gz
5454

5555
# install sphinx et al
56+
ENV PIP_BREAK_SYSTEM_PACKAGES=1
5657
RUN pip3 install \
5758
ablog \
5859
attrs \
@@ -75,8 +76,13 @@ RUN pip3 install \
7576
sphinxcontrib-bibtex
7677

7778
RUN pip3 install \
78-
--index-url https://urm.nvidia.com/artifactory/api/pypi/ct-omniverse-pypi/simple/ \
79-
nvidia-sphinx-theme
79+
--extra-index-url https://pypi.nvidia.com \
80+
nvidia-sphinx-theme \
81+
sphinx==7.4.7
82+
83+
RUN curl -fL https://install-cli.jfrog.io | sh
84+
85+
RUN git config --global --add safe.directory "*"
8086

8187
# Set visitor script to be included on every HTML page
8288
ENV VISITS_COUNTING_SCRIPT="//assets.adobedtm.com/b92787824f2e0e9b68dc2e993f9bd995339fe417/satelliteLib-7ba51e58dc61bcb0e9311aadd02a0108ab24cc6c.js"

docs/conf.py

Lines changed: 83 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -35,9 +35,12 @@
3535
# -- Path setup --------------------------------------------------------------
3636

3737
import json
38+
import logging
3839
import os
3940
import re
41+
import subprocess
4042
from datetime import date
43+
from logging.handlers import RotatingFileHandler
4144

4245
# If extensions (or modules to document with autodoc) are in another directory,
4346
# add these directories to sys.path here. If the directory is relative to the
@@ -61,6 +64,45 @@
6164
# at the end of the file.
6265
# current_dir = os.getcwd()
6366
# os.chdir("docs")
67+
# -- Setup logger ------------------------------------------------------------
68+
69+
70+
def setup_logger(name, log_file, level=logging.INFO, max_bytes=1048576, backup_count=5):
71+
logger = logging.getLogger(name)
72+
logger.setLevel(level)
73+
74+
# Prevent adding multiple handlers if the function is called multiple times
75+
if not logger.handlers:
76+
# Create handlers
77+
file_handler = RotatingFileHandler(
78+
log_file, maxBytes=max_bytes, backupCount=backup_count
79+
)
80+
console_handler = logging.StreamHandler()
81+
82+
# Set the logging level for handlers
83+
file_handler.setLevel(level)
84+
console_handler.setLevel(level)
85+
86+
# Create a logging format
87+
BLUE = "\033[94m"
88+
RESET = "\033[0m"
89+
formatter = logging.Formatter(
90+
f"{BLUE}%(asctime)s - %(name)s - %(levelname)s - {RESET}%(message)s"
91+
)
92+
file_handler.setFormatter(formatter)
93+
console_handler.setFormatter(formatter)
94+
95+
# Add handlers to the logger
96+
logger.addHandler(file_handler)
97+
logger.addHandler(console_handler)
98+
return logger
99+
100+
101+
logger = setup_logger(
102+
os.path.basename(__file__),
103+
os.environ.get("TRITON_SERVER_DOCS_LOG_FILE", "/tmp/docs.log"),
104+
)
105+
logger.info(f"Defined logger for {os.path.basename(__file__)}")
64106

65107
# -- Project information -----------------------------------------------------
66108

@@ -70,14 +112,19 @@
70112

71113
# Get the version of Triton this is building.
72114
version_long = "0.0.0"
115+
logger.info(f"Getting version from ../TRITON_VERSION")
73116
with open("../TRITON_VERSION") as f:
74117
version_long = f.readline()
75118
version_long = version_long.strip()
119+
logger.info(f"Version: {version_long}")
120+
76121

77122
version_short = re.match(r"^[\d]+\.[\d]+\.[\d]+", version_long).group(0)
123+
logger.info(f"Version short: {version_short}")
78124
version_short_split = version_short.split(".")
125+
logger.info(f"Version short split: {version_short_split}")
79126
one_before = f"{version_short_split[0]}.{int(version_short_split[1]) - 1}.{version_short_split[2]}"
80-
127+
logger.info(f"One before: {one_before}")
81128

82129
# maintain left-side bar toctrees in `contents` file
83130
# so it doesn't show up needlessly in the index page
@@ -180,7 +227,7 @@
180227
"json_url": "https://docs.nvidia.com/deeplearning/triton-inference-server/user-guide/docs/_static/switcher.json",
181228
"version_match": one_before if "dev" in version_long else version_short,
182229
},
183-
"navbar_start": ["navbar-logo", "version-switcher"],
230+
# "navbar_start": ["navbar-logo", "version-switcher"],
184231
"primary_sidebar_end": [],
185232
}
186233

@@ -194,6 +241,8 @@
194241
}
195242
)
196243

244+
logger.info(f"html_theme_options: {html_theme_options}")
245+
197246
deploy_ngc_org = "nvidia"
198247
deploy_ngc_team = "triton"
199248
myst_substitutions = {
@@ -203,6 +252,8 @@
203252
else deploy_ngc_org,
204253
}
205254

255+
logger.info(f"myst_substitutions: {myst_substitutions}")
256+
206257

207258
def ultimateReplace(app, docname, source):
208259
result = source[0]
@@ -219,6 +270,7 @@ def ultimateReplace(app, docname, source):
219270
if deploy_ngc_team
220271
else deploy_ngc_org,
221272
}
273+
logger.info(f"ultimate_replacements: {ultimate_replacements}")
222274

223275
# bibtex_bibfiles = ["references.bib"]
224276
# To test that style looks good with common bibtex config
@@ -233,25 +285,30 @@ def ultimateReplace(app, docname, source):
233285
# SETUP SWITCHER
234286
###############################
235287
switcher_path = os.path.join(html_static_path[0], "switcher.json")
288+
logger.info(f"switcher_path: {switcher_path}")
236289
versions = []
237290
# Triton 2 releases
238-
correction = -1 if "dev" in version_long else 0
239-
upper_bound = version_short.split(".")[1]
240-
for i in range(2, int(version_short.split(".")[1]) + correction):
241-
versions.append((f"2.{i}.0", f"triton-inference-server-2{i}0"))
242-
243-
# Triton 1 releases
244-
for i in range(0, 15):
245-
versions.append((f"1.{i}.0", f"tensorrt_inference_server_1{i}0"))
246-
247-
# Triton Beta Releases
248-
for i in range(1, 11):
249-
versions.append((f"0.{i}.0_beta", f"inference_server_0{i}0_beta"))
291+
# correction = -1 if "dev" in version_long else 0
292+
# upper_bound = version_short.split(".")[1]
293+
# for i in range(2, int(version_short.split(".")[1]) + correction):
294+
# versions.append((f"2.{i}.0", f"triton-inference-server-2{i}0"))
295+
# logger.info(f"Found Triton 2 releases: {versions}")
296+
297+
# Obtain Triton Server Release Tags.
298+
tags = subprocess.run(["git", "tag", "--list", "v*"], capture_output=True, text=True)
299+
tags_list = sorted(tags.stdout.strip().splitlines(), key=Version, reverse=True)
300+
logger.info(f"Found source tags: {tags_list}")
301+
302+
for v in tags_list:
303+
versions.append(
304+
(
305+
v.replace("v", ""),
306+
f"triton-inference-server-{v.replace('v', '').replace('.', '')}",
307+
)
308+
)
250309

251-
# Patch releases
252-
# Add here.
310+
logger.info(f"Defined dictionary of versions: {versions}")
253311

254-
versions = sorted(versions, key=lambda v: Version(v[0]), reverse=True)
255312

256313
# Build switcher data
257314
json_data = []
@@ -263,6 +320,7 @@ def ultimateReplace(app, docname, source):
263320
"url": f"https://docs.nvidia.com/deeplearning/triton-inference-server/archives/{v[1]}/user-guide/docs",
264321
}
265322
)
323+
266324
if "dev" in version_long:
267325
json_data.insert(
268326
0,
@@ -284,6 +342,7 @@ def ultimateReplace(app, docname, source):
284342

285343
# Trim to last N releases.
286344
json_data = json_data[0:12]
345+
logger.info(f"Trimmed to last 12 release...")
287346

288347
json_data.append(
289348
{
@@ -293,19 +352,22 @@ def ultimateReplace(app, docname, source):
293352
}
294353
)
295354

296-
# validate the links
297355
for i, d in enumerate(json_data):
356+
logger.info(f"Validating link: {d['url']}")
298357
h = httplib2.Http()
299358
resp = h.request(d["url"], "HEAD")
300359
if int(resp[0]["status"]) >= 400:
301360
print(d["url"], "NOK", resp[0]["status"])
302-
exit(1)
361+
# exit(1)
303362

304-
# Write switcher data to file
363+
logger.info(f"Writing switcher data to file: {switcher_path}")
305364
with open(switcher_path, "w") as f:
306365
json.dump(json_data, f, ensure_ascii=False, indent=4)
307366

308367

368+
logger.info("Configuration completed...")
369+
370+
309371
def setup(app):
310372
app.add_config_value("ultimate_replacements", {}, True)
311373
app.connect("source-read", ultimateReplace)

0 commit comments

Comments
 (0)