Skip to content

Commit f015cf1

Browse files
authored
Merge pull request #85791 from iamleeg/iamleeg/build-static-stdlib-docs
Add options to the build-stdlib-docs target to transform docs for static hosting.
2 parents cef53c6 + 33edffa commit f015cf1

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,12 @@ def create_argument_parser():
12521252
default=False,
12531253
help='Build and preview standard library documentation with Swift-DocC.'
12541254
'Note: this builds Swift-DocC to perform the docs build.')
1255+
option('--stdlib-docs-static-hosting', toggle_true,
1256+
default=False,
1257+
help='Build the standard library documentation for static hosting.')
1258+
option('--stdlib-docs-hosting-base-path', store,
1259+
default='/',
1260+
help='The base path for hosting the standard library documentation.')
12551261

12561262
option('--build-swift-clang-overlays', toggle_true,
12571263
default=True,

utils/build_swift/tests/expected_options.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@
293293
'swift_user_visible_version': defaults.SWIFT_USER_VISIBLE_VERSION,
294294
'build_stdlib_docs': False,
295295
'preview_stdlib_docs': False,
296+
'stdlib_docs_static_hosting': False,
297+
'stdlib_docs_hosting_base_path': '/',
296298
'symbols_package': None,
297299
'clean_libdispatch': True,
298300
'clean_foundation': True,
@@ -609,6 +611,7 @@ class BuildScriptImplOption(_BaseOption):
609611
SetTrueOption('--wasmkit', dest='build_wasmkit'),
610612
SetTrueOption('--build-stdlib-docs'),
611613
SetTrueOption('--preview-stdlib-docs'),
614+
SetTrueOption('--stdlib-docs-static-hosting'),
612615
SetTrueOption('-B', dest='benchmark'),
613616
SetTrueOption('-S', dest='skip_build'),
614617
SetTrueOption('-b', dest='build_llbuild'),
@@ -839,6 +842,8 @@ class BuildScriptImplOption(_BaseOption):
839842
SetTrueOption('--swift-freestanding-is-darwin'),
840843
AppendOption('--extra-swift-cmake-options'),
841844

845+
StrOption('--stdlib-docs-hosting-base-path'),
846+
842847
StrOption('--linux-archs'),
843848
StrOption('--linux-static-archs'),
844849

utils/swift_build_support/swift_build_support/products/stdlib_docs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from . import swiftdoccrender
1818
from .. import shell
1919

20-
2120
class StdlibDocs(product.Product):
2221
@classmethod
2322
def is_build_script_impl_product(cls):
@@ -42,10 +41,13 @@ def build(self, host_target):
4241
os.path.dirname(self.build_dir),
4342
f'swift-{host_target}'
4443
)
44+
4545
symbol_graph_dir = os.path.join(swift_build_dir, "lib", "symbol-graph")
4646
output_path = os.path.join(swift_build_dir, "Swift.doccarchive")
4747

4848
docc_action = 'preview' if self.args.preview_stdlib_docs else 'convert'
49+
static_hosting_option = '--transform-for-static-hosting' if self.args.stdlib_docs_static_hosting else ''
50+
hosting_base_path = self.args.stdlib_docs_hosting_base_path
4951

5052
docc_cmd = [
5153
docc_path,
@@ -60,6 +62,9 @@ def build(self, host_target):
6062
"Swift",
6163
"--fallback-bundle-identifier",
6264
"org.swift.swift",
65+
static_hosting_option,
66+
"--hosting-base-path",
67+
hosting_base_path
6368
]
6469

6570
shell.call(docc_cmd)

0 commit comments

Comments
 (0)