-
Notifications
You must be signed in to change notification settings - Fork 414
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
Add support for Jazzy for code where a Xcode project doesn't exist #487
Comments
You could create a podspec for it, but all that would do is automate the creation of a xcodeproject for you. |
Yeah, jazzy basically requires an Xcode project to detect what the entirety of the There are definitely ways to avoid the Xcode dependency, but they're certainly not documented and would require some minor modifications to jpsim/SourceKitten, but you'd still need deep knowledge of how that works to do those small changes. So I'm afraid you're on your own here (unless you follow @orta's advice) until jazzy adds support for something like the Swift Package Manager. |
This would be a great feature as I have a framework with no Xcode project. |
Converting this issue from a question to a feature request since I agree with @kylebrowning. That would be a cool feature, especially with SPM and non-Xcode proj Swift code. |
@istx25 any progress? |
We have not actively started working on this feature, afaik. Feel free to take on the feature if you'd like to though. |
On which technology this feature can be written? |
SourceKitten is written in Swift and Jazzy is written in Ruby. I'm not exactly sure where these changes need to be made but definitely feel free to look into that or @jpsim could probably put you in the right direction. |
Who knows, maybe I will find some time for implementing this useful feature. |
I’m not familiar with RemObjects Fire, but I use jazzy with the Swift Package Manager. swift package generate-xcodeproj
jazzy Making a different type of project look enough like a package to let the Swift Package Manager generate the Xcode project may be relatively simple. Try something like this as a bare‐bones starting point: cd ../Somewhere/Outside/The/Project
mkdir TemporaryPackage
cd TemporaryPackage
swift package init
cp -r /Path/Of/Actual/Project/Root Sources/TemporaryPackage
rm Sources/TemporaryPackage.swift
swift package generate-xcodeproj
jazzy
cp -r docs /Path/Of/Documentation/Output
cd ..
rm -rf TemporaryPackage With real paths, the above script is already sufficient to run jazzy, provided the project contains only I wrote it in shell so it is fast to try, but the script can also be re‐writen in whatever language you like (Jazzy is in Ruby). Once you get it working for your project, if you decide to modify it to be widely‐applicable and no longer hard coded for your particular project, you can submit a pull request. I suspect the simplest way to integrate this into Jazzy itself would be a Jazzy configuration option (something like Note: All this still assumes Xcode itself is present on the system. Making Jazzy work without it would be tantamount to starting Jazzy over from scratch. Ergo, Jazzy will never run on Linux. |
If your project supports the Swift Package Manager, you don't need an Xcode project to generate docs for it. For example:
Which generates this: https://static.realm.io/jazzy_demo/Vapor At some point, I'll build a more direct way to do this with a single command using jazzy. But right now, it's not too complicated, just three commands: |
@jpsim Link is 404 |
it's still uploading. Shouldn't take more than another 60 seconds. |
This doesnt work with iOS, tvOS, or watchOS executables because swift build only builds executables for the host system. |
@kylebrowning my comment above explicitly stated that this is an option of your project supports the Swift Package Manager... |
Edit: This comment is obsolete. See the next comment instead.
@kylebrowning, the package just has to build on the host system; it need not actually run. For some iOS (et al.) frameworks, the Swift Package Manager may still be a reasonable hack until something better comes along. The amount of work it involves depends on the particular project and how many iOS‐only symbols it deals with. Function implementations the host system cannot build can be surrounded with: /// Documention that should generate.
public func doSomething() -> String {
#if os(macOS)
return String()
#else
// Actual implementation here.
#endif
} That way, on iOS, nothing has changed, but macOS can now build the API. The same can be done to Problematic parameter types and return values can be solved by defining empty versions of those types for macOS: #if os(macOS)
/// :nodoc:
public struct UIView {}
#endif |
I didn’t let that stop me. Workspace can now stitch the Swift Package Manager, iOS, and Jazzy together. To see a demonstration, paste the following script into Terminal, and voilà—instant documentation. (Assuming Xcode 8.2.1 and Jazzy 0.7.4 are on the local device.) # Create an empty package
mkdir MyLibrary
cd MyLibrary
swift package init
git init
cd ..
# Delete the template code:
rm -rf MyLibrary/Sources/MyLibrary.swift
rm -rf MyLibrary/Tests
# Add OS‐specific code:
echo $'#if os(macOS)\n /// Does macOS stuff.\n public func doMacOSStuff() {}\n#elseif os(iOS)\n /// Does iOS stuff.\n public func doIOSStuff() {}\n#elseif os(watchOS)\n /// Does watchOS stuff.\n public func doWatchOSStuff() {}\n#elseif os(tvOS)\n /// Does tvOS stuff.\n public func doTVOSStuff() {}\n#endif' > MyLibrary/Sources/MyLibrary.swift
# Display source
open MyLibrary/Sources/MyLibrary.swift
# Make sure Workspace is installed
# More Information: https://github.com/SDGGiesbrecht/Workspace#workspace
git clone https://github.com/SDGGiesbrecht/Workspace
Workspace/Refresh\ Workspace\ \(macOS\).command
rm -rf Workspace
# Apply Workspace to the project
# More Information: https://github.com/SDGGiesbrecht/Workspace#setup
cd MyLibrary
~/.Workspace/Workspace/.build/release/workspace refresh
cd ..
# Configure Workspace
# More Information: https://github.com/SDGGiesbrecht/Workspace/blob/master/Documentation/Configuring Workspace.md#configuring-workspace
echo $'Manage Xcode: True\nGenerate Documentation: True\nAutomatically Take On New Responsibilities: False\nSkip Simulator: True' > "MyLibrary/.Workspace Configuration.txt"
# Run Workspace (which includes Jazzy)
# More Information: https://github.com/SDGGiesbrecht/Workspace/blob/master/Documentation/Documentation Generation.md#documentation-generation
cd MyLibrary
~/.Workspace/Workspace/.build/release/workspace validate
cd ..
# Display result
open MyLibrary/docs/macOS/index.html
open MyLibrary/docs/iOS/index.html
open MyLibrary/docs/watchOS/index.html
open MyLibrary/docs/tvOS/index.html @kylebrowning, let me know if there are additional project‐specific hurdles still in the way. |
Any news here? I would like to run Jazzy as step in my CI on a Linux system. Any hope to support this one day? |
@cianiandreadev, there is still no progress towards Linux support within the Jazzy project itself—Jazzy is built on top of Xcode. However, if...
...then Workspace can be easily set up with Travis CI to run Jazzy remotely and push the documentation to a In this manner Jazzy can be used even if all you have locally are Linux machines. |
Well, sourcekitten runs on Linux and supports SPM directly, so the technique in #487 (comment) should work -- no Xcode dependencies I can see? |
...sort of. It takes extra work and know‐how to set up and even then is somewhat unreliable. Two significant complications are the out‐of‐package dependency on SourceKit and the fact that Foundation is not integral to the operating system. Anyone considering this route may find it useful to read these related issues in the repositories for SourceKitten and SwiftLint (another SourceKitten client): realm/SwiftLint#732, jpsim/SourceKitten#433, realm/SwiftLint#2026. I have tried three separate times over the last year to write a script that could reliably shim SourceKitten and smooth over the complications, but I have been forced to give up each time. (If someone else succeeds, I will happily be the first to start using it.) But yes, if you can get SourceKitten working, then the technique farther up is viable on Linux. Note that the technique is very straightforward on macOS. |
SourceKitten is much easier to use from Linux now. The notes in the last few comments are out of date. |
I have a Swift project that is not a Xcode project, it is a RemObjects Fire project - https://github.com/loretoparisi/swift-promise-example.
If I try to run jazzy from the sources folder
src/
(that is here: https://github.com/loretoparisi/swift-promise-example/tree/master/StaticLibrary/SharedProject/src ) I get an error that I suppose is due to the fact that this is not a Xcode project:So is it possibile to run jazzy for non Xcode projects?
The text was updated successfully, but these errors were encountered: