-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
A new `@TitleHeading` metadata directive for customizing the text of a page-title heading (also known as an eyebrow or kick). `@TitleHeading` accepts an unnamed parameter containing containing the page-title’s heading text. @metadata { @TitleHeading("Release Notes") } This feature has been pitched on the forums here: https://forums.swift.org/t/supporting-more-types-of-documentation-with-swift-docc/59725#titleheading-10 rdar://110662981
- Loading branch information
1 parent
08df11b
commit 6f72447
Showing
15 changed files
with
344 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2023 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import Foundation | ||
import Markdown | ||
|
||
/// A directive for customizing the text of a page's title heading. | ||
/// | ||
/// The ``heading`` property will override the page's default title heading. | ||
/// | ||
/// @TitleHeading accepts an unnamed parameter containing containing the page's title heading. | ||
/// | ||
/// This directive is only valid within a top-level ``Metadata`` directive: | ||
/// ```markdown | ||
/// @Metadata { | ||
/// @TitleHeading("Release Notes") | ||
/// } | ||
/// ``` | ||
public final class TitleHeading: Semantic, AutomaticDirectiveConvertible { | ||
public let originalMarkup: BlockDirective | ||
|
||
/// An unnamed parameter containing containing the page-title’s heading text. | ||
@DirectiveArgumentWrapped(name: .unnamed) | ||
public var heading: String | ||
|
||
static var keyPaths: [String : AnyKeyPath] = [ | ||
"heading" : \TitleHeading._heading, | ||
] | ||
|
||
@available(*, deprecated, message: "Do not call directly. Required for 'AutomaticDirectiveConvertible'.") | ||
init(originalMarkup: BlockDirective) { | ||
self.originalMarkup = originalMarkup | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...cc/DocCDocumentation.docc/Reference Syntax/API Reference Syntax/TitleHeading.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# ``docc/TitleHeading`` | ||
|
||
A directive that specifies a title heading for a given documentation page. | ||
|
||
@Metadata { | ||
@DocumentationExtension(mergeBehavior: override) | ||
} | ||
|
||
- Parameters: | ||
- heading: The text for the custom title heading. | ||
|
||
## Overview | ||
|
||
Place the `TitleHeading` directive within a `Metadata` directive to configure a documentation page to show a custom title heading. Custom title headings, along with custom [page icons](doc:PageImage) and [page colors](doc:PageColor), allow for the creation of custom kinds of pages beyond just articles. | ||
|
||
A title heading is also known as a page eyebrow or kicker. | ||
|
||
``` | ||
# ``SlothCreator`` | ||
@Metadata { | ||
@TitleHeading("Release Notes") | ||
} | ||
``` | ||
|
||
A custom title heading appears in place of the page kind at the top of the page. | ||
### Containing Elements | ||
|
||
The following items can include a title heading element: | ||
|
||
@Links(visualStyle: list) { | ||
- ``Metadata`` | ||
} | ||
|
||
<!-- Copyright (c) 2023 Apple Inc and the Swift Project authors. All Rights Reserved. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.