Hi all!
I'm excited to pitch the final piece (for now) of the authoring story for supporting more kinds of documentation in Swift-DocC. This pitch is a sibling of the following:
- Supporting more types of documentation with Swift-DocC
- Supporting more dynamic content in Swift-DocC reference documentation
Problem
The introduction of @TopicsVisualStyle
highlights a current deficiency in Swift-DocC's linking story. Links authored in a topics section like so:
## Topics
### Heading
- <doc:article>
receive a special visual treatment where they can be rendered with their abstract and, now, with their card image. However, writing links in a topics section also organizes the linked pages as children of the current page in the navigation sidebar. And there's no way to replicate this visual treatment outside of a topics section. So, if a writer wants to highlight a certain page in their documentation using the topics section visual style, they're now forced to also organize that page as a child which may lead to a sub-optimal navigation sidebar.
We should provide another way to author visual links to pages without the side affect of organizing those pages as children of the current page.
Solution
A new @Links
directive that allows for authoring a Topics section anywhere on the page without affecting page curation behavior. @Links
gives authors flexibility in choosing how they want to highlight documentation on the page itself versus in the navigation sidebar. It also allows for mixing and matching different visual styles of topics.
This would, for example, allow a developer to add a “What’s New” section to their top-level framework page:
# ``SlothCreator``
Catalog sloths you find in nature and create new adorable virtual sloths.
@Options {
@TopicsVisualStyle(detailedGrid)
}
## Overview
SlothCreator provides models and utilities for creating, tracking, and caring for sloths.
You can visualize and observe your sloths by adding a ``SlothView`` to a SwiftUI view structure.
![A sloth hanging off a tree.](sloth.png)
### What's New in SlothCreator
@Links(visualStyle: compactGrid) {
- <doc:get-started-preparing-sloth-food>
- <doc:feeding-your-sloth-in-winter>
- <doc:ordering-food-delivery>
}
## Topics
### Essentials
- <doc:/tutorials/SlothCreator>
- <doc:GettingStarted>
- ``Sloth``
### Creating a Sloth
- ``SlothGenerator``
- ``NameGenerator``
...
Thus, highlighting pages that are otherwise logically organized as children of other pages without needing to curate them twice and potentially confuse the experience of the navigation sidebar.
Details
@Links
accepts a single visualStyle
parameter and supports a list of Swift-DocC links as its child content:
-
visualStyle
: The visual style of the topic links. Accepts one of the following:-
list
: Matches the current default Topics section style Swift-DocC uses. Includes the abstract for each page. -
compactGrid
: Matches the newcompactGrid
topics section visual style. A grid of items based on the card image for each page. Includes each page’s title and card image but excludes their abstracts. -
detailedGrid
: Matches the newdetailedGrid
topics section visual style option. A grid of items based on the card image for each page. Includes the abstract for each page.
-
@Links
adds a lot of flexibility to on-page documentation organization. When combined with other directives like @Row
/@Column
the possibility for really unique documentation sites created with Swift-DocC is exciting. I'm looking forward to hearing your feedback on the naming and functionality of this new directive.