-
Notifications
You must be signed in to change notification settings - Fork 55
swift-docc-plugin produces documentation for last target only #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There's a use-case where this creates even more confusion. // swift-tools-version:5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyPackage",
products: [
.library(
name: "MyFramework",
targets: ["SomeTarget", "SomeOtherTarget"]),
.library(
name: "MyIrrelevantFramework",
targets: ["IrrelevantTarget"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
],
targets: [
.target(name: "SomeTarget"),
.target(name: "SomeOtherTarget"),
.target(name: "IrrelevantTarget"),
]
) Now I'd like to build the documentation for the
This generates the documentation for |
This is probably related to this discussion. |
Having a root index.html that links to all the targets would certainly fix that issue. If this issue is addressed but doesn't include the root index.html change I'll open another issue. |
Hi @JosephDuffy! Thanks for opening this. I think there's a couple of things going on here. The first is that today Swift-DocC only supports generating documentation for a single target at a time. I would definitely be interested in better supporting the use case where you'd like to host documentation for multiple targets on one site, but we'd need to address that in Swift-DocC itself first and then just adopt the feature in the plugin. Filing an issue on the Swift-DocC repo for this would be really appreciated. Because of this current limitation, the So as things stand today you can either:
I think we should improve the documentation to note this and add a diagnostic that's emitted when the Is it okay with you if we use this issue to track the diagnostic/documentation improvement as the resolution? And we can look into expanding Swift-DocC to support multi-target documentation in parallel. |
@ffried this is incorrect. While users will be able to add a single |
@ethan-kusters You're absolutely right - my bad! |
Done: swiftlang/swift-docc#255 |
Just for reference here as well: We're already merging the documentation for multiple targets. It's far from nice, but it works for now. We could save ourselves a lot of work though, if docc is able to do this on its own. For details, see this comment. |
That makes sense, thank you for explaining!
That would be a good idea. I had noticed that package plugins supported multiple targets and that the generated static website included the name of the target so I assumed it would all work.
That's ok. Is it likely that we'll need another issue to actually support the multiple targets once support is added to Swift-DocC? Do you think having a homepage linking to all the targets would fall under that work, or tracked separately? |
Is this issue something that a skilled outsider could help resolve? It would be really lively to have multiple products from one Swift Package covered somehow 😌 |
At some point I will look into the actual Swift code and see how docc is generating the documentation, but this is the bash script I am using to generate documentation for all the targets: #!/bin/bash
mkdir -p docs/
for target in "$@"
do
echo "Generating docs for $target"
swift package --allow-writing-to-directory "$target-docs" generate-documentation --disable-indexing --transform-for-static-hosting --hosting-base-path swift-gopher --output-path "$target-docs" --target "$target"
cp -r $target-docs/* docs/
modified_target=$(echo $target | tr '-' '_' | tr '[:upper:]' '[:lower:]')
cp -r $target-docs/index/index.json "docs/index/$modified_target.json"
done
echo "<!DOCTYPE html><html><head><meta http-equiv=\"refresh\" content=\"0; url=/swift-gopher/documentation/\" /></head><body><ol>" > docs/index.html
for target in "$@"
do
cp -R $target-docs/data/documentation/* docs/data/documentation/
cp -R $target-docs/documentation/* docs/documentation/
rm -r "$target-docs"
modified_target=$(echo $target | tr '-' '_' | tr '[:upper:]' '[:lower:]')
echo "<li><a href=\"/swift-gopher/documentation/$modified_target/\">$target</a></li>" >> docs/index.html
done
echo "</ol></body></html>" >> docs/index.html
custom_javascript="window.location.pathname.split('documentation/')[1].split('/')[0]"
file_to_modify=$(ls docs/js/documentation-topic\~topic\~tutorials-overview.*.js)
sed -i '' 's/"index.json"/window.location.pathname.split("documentation\/")[1].split("\/")[0]+".json"/g' $file_to_modify
echo "Modified $file_to_modify" Earlier you could just copy everything from $target/documentation/ and $target/data/documentation, but the JavaScript file for loading the sidebar relies on
This bash script works for deploying the static documentation on GitHub pages using the docs dir. Modify as needed |
This was recently fixed by #89 which is available in the 1.4 release:
|
Describe the bug
When using
swift-docc-plugin
to generate documentation any target's documentation will overwrite previously generated documentation. For example if a package has "TargetA" and "TargetB" and the commandswift package --allow-writing-to-directory "./docs" generate-documentation --disable-indexing --output-path "./docs" --transform-for-static-hosting --hosting-base-path "PackageName"
is run it will generate the documentation for "TargetA" and then "TargetB", but the documentation for "TargetB" will overwrite "TargetA".To Reproduce
Steps to reproduce the behavior:
swift-docc-plugin
as a dependencyswift package --allow-writing-to-directory "./docs" generate-documentation --disable-indexing --output-path "./docs" --transform-for-static-hosting --hosting-base-path "PackageName"
Expected behavior
A directory suitable for static hosting should be generated, which contains the documentation for "TargetA" and "TargetB".
I think the root
index.html
should provide links to both of these targets, but I'm not sure if this is an expected feature or a new feature request.Screenshots
N/A
Environment (please complete the following information):
swift-docc-plugin
: 1.0.0Additional context
N/A
The text was updated successfully, but these errors were encountered: