Autogenerate documentation for settings

This commit is contained in:
Alexey Milovidov 2024-10-17 00:32:57 +02:00
parent df6d984d10
commit 4095963b0a
2 changed files with 58 additions and 1 deletions

View File

@ -9,7 +9,7 @@ RUN CGO_ENABLED=0 go install github.com/wjdp/htmltest@v${HTMLTEST_VERSION} \
# nodejs 17 prefers ipv6 and is broken in our environment
FROM node:16-alpine
RUN apk add --no-cache git openssh bash
RUN apk add --no-cache git openssh bash curl
# At this point we want to really update /opt/clickhouse-docs directory
# So we reset the cache
@ -33,4 +33,7 @@ RUN mkdir /output_path \
COPY run.sh /run.sh
COPY --from=htmltest-builder /usr/bin/htmltest /usr/bin/htmltest
# Install ClickHouse Local, which is used to auto-generate some doc pages.
RUN curl https://clickhouse.com/ | sh && ./clickhouse install -y
ENTRYPOINT ["/run.sh"]

View File

@ -21,6 +21,60 @@ do
fi
done
# Generate pages with settings
ch -q "
WITH
'/ClickHouse/docs/en/operations/settings/settings.md' AS doc_file,
'/ClickHouse/src/Core/Settings.cpp' AS cpp_file,
settings_from_cpp AS
(
SELECT extract(line, 'M\(\w+, (\w+),') AS name
FROM file(cpp_file, LineAsString)
WHERE match(line, '^\s*M\(')
),
main_content AS
(
SELECT format('## {} {}\n\nType: {}\n\nDefault value: {}\n\n{}\n\n', name, '{#'||name||'}', type, default, trim(BOTH '\n' FROM description))
FROM system.settings WHERE name IN settings_from_cpp
ORDER BY name
),
(SELECT extract(raw_blob, '(^(?:[^#]|#[^#])+)##') FROM file(doc_file, RawBLOB)) AS prefix
SELECT prefix || (SELECT groupConcat(*) FROM main_content)
INTO OUTFILE '/opt/clickhouse-docs/docs/en/operations/settings/settings.md' TRUNCATE FORMAT LineAsString
"
ch -q "
WITH
'/ClickHouse/docs/en/operations/settings/settings-formats.md' AS doc_file,
'/ClickHouse/src/Core/FormatFactorySettingsDeclaration.h' AS cpp_file,
settings_from_cpp AS
(
SELECT extract(line, 'M\(\w+, (\w+),') AS name
FROM file(cpp_file, LineAsString)
WHERE match(line, '^\s*M\(')
),
main_content AS
(
SELECT format('## {} {}\n\nType: {}\n\nDefault value: {}\n\n{}\n\n', name, '{#'||name||'}', type, default, trim(BOTH '\n' FROM description))
FROM system.settings WHERE name IN settings_from_cpp
ORDER BY name
),
(SELECT extract(raw_blob, '(^(?:[^#]|#[^#])+)##') FROM file(doc_file, RawBLOB)) AS prefix
SELECT prefix || (SELECT groupConcat(*) FROM main_content)
INTO OUTFILE '/opt/clickhouse-docs/docs/en/operations/settings/settings-formats.md' TRUNCATE FORMAT LineAsString
"
# Force build error on wrong symlinks
sed -i '/onBrokenMarkdownLinks:/ s/ignore/error/g' docusaurus.config.js