-
Notifications
You must be signed in to change notification settings - Fork 146
[docs] Add basic documentation on using Snippets to DocC documentation #1166
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
base: main
Are you sure you want to change the base?
Conversation
FYI: You can coauthor commits by including a line like this in the commit message:
|
Sources/docc/DocCDocumentation.docc/Reference Syntax/API Reference Syntax/Snippet.md
Outdated
Show resolved
Hide resolved
@JacobHearst @d-ronnqvist sorry for the delay in writing an overview. Added one based on @d-ronnqvist feedback, see what you think. |
@swift-ci please test |
@swift-ci please tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great! Thank you so much for writing these docs 👏 This is a very cool feature that most people aren't even aware of.
Just a curation issue and another minor tweak please.
Sources/docc/DocCDocumentation.docc/Reference Syntax/API Reference Syntax/Snippet.md
Outdated
Show resolved
Hide resolved
Thanks @patshaughnessy - accepted all suggestions and added a commit to rename the file per your suggestion. |
@swift-ci please test |
Hello @heckj - sorry for the delay. I wasn't able to make this work following the instructions in your new article. I suspect that Swift DocC users have to add the Swift DocC Plugin as a dependency in their Package.swift, and then build the docs using the Would you mind updating the article to show how to do this? For example, the article might include details about these steps:
Without all of this information spelled out, I don't know how many readers will be able to use the feature successfully. Let me know if you need help and I can push a draft of what this might look like. |
Thanks for looking @patshaughnessy ! I don't think you strictly need the plugin to do this, but it's certainly easier than wrangling the independent steps of using To my knowledge, this capability hasn't been enabled with Xcode, and is only functional when building and rendering documentation using the Swift Package Manager. The core pieces for building the snippets are part of that project, and generally I do tend to add the swift-docc-plugin to a package when I'm working on such documentation. |
@patshaughnessy I added in an early section explicitly calling out adding the swift-docc-plugin in order to view the snippets, but stopped short of adding sections that illustrate creating a project and making this more of a tutorial-like walkthrough, since that's not done for any of the other proximate documentation. Give it a read and see what you think, and I'd happily take updates or a draft of what you'd like to see to make this easier to use. (I've also rebased this branch to catch it up a bit) |
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great thank you!
FYI I added a couple of things to your article that I hope will make things a bit more clear for readers:
- An ASCII art diagram of where the files go. I was confused by how the
Snippets
folder goes under the root directory, while the documentation catalog goes under theSources
directory. I couldn't get it all working until I realized this. - A complete markdown example, showing how the module name goes in the
@Snippet
directory (as you explained) but also in the H1 tag at the top, which I forgot about.
Hope this helps!
FYI this bit didn't work for me:
DocC parses contiguous comments within the code of a snippet as markdown to annotate your code when embedded in documentation. DocC will attempt to reference symbols from within these comments just like any other documentation content. You can reference symbols from your API, which DocC converts into hyperlinks to that symbol when displaying the content.
I don't know if there's a bug, or if I misunderstood what you were saying. But we can figure that out later in another PR. This is a huge step forward in the docs, so let's merge it.
Let me know if my additions look good to you, and I'll merge it. Thanks again. |
Looks great @patshaughnessy - Thanks for the additions! No worries with the comments in snippets as markdown - happy to leave that to follow ups and just get the baseline docs out there! |
@swift-ci please test |
Sources/docc/DocCDocumentation.docc/Reference Syntax/API Reference Syntax/Snippet.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/Reference Syntax/API Reference Syntax/Snippet.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Show resolved
Hide resolved
Thanks David - I'll go back and revise to align properly and shift some of the content - hadn't clued into |
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
Sources/docc/DocCDocumentation.docc/adding-code-snippets-to-your-content.md
Outdated
Show resolved
Hide resolved
@swift-ci please test |
1 similar comment
@swift-ci please test |
Co-authored-by: Joe Heck <[email protected]> Co-authored-by: Jacob Hearst <[email protected]>
…a newline to the end of the file
…erated symbolgraph with that change
Co-authored-by: Pat Shaughnessy <[email protected]>
Co-authored-by: Pat Shaughnessy <[email protected]>
…ence Syntax/Snippet.md Co-authored-by: Pat Shaughnessy <[email protected]>
make it clear where the snippets go, and also where the documentation catalog goes. Also show a concrete example of how to reference a snippet. Fix a typo.
…an extension page
…ur-content.md Co-authored-by: David Rönnqvist <[email protected]>
(rebased and resolved the feedback - trimmed down some of the example, per David's feedback. Left the bits that Pat explicitly requested in) |
@swift-ci please test |
Work towards resolving #417
Summary
Adds some base line documentation that describes how to use the snippets feature built in to DocC and the DocC Plugin.
Dependencies & Testing
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded(this pull request is the combined work of https://github.com/JacobHearst and myself, I just happen to be submitting it)