-
Notifications
You must be signed in to change notification settings - Fork 60
Add support for the @Image
directive
#404
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 the @Image
directive
#404
Conversation
…tract, but not anchor. use the `metadata.title` to determine if a figure caption should be above/below the content
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.
Tested with the DocC branch and looks good (no actual spec changes needed for the image specifically it seems).
The only potential issue I noticed is that the proposal for this new directive showed examples where the caption text is centered underneath the image as opposed to left aligned as it is now. If we were to support that, we may need to update the directive itself to allow for both alignments (because we already support the left aligned ones for older content).
That is a great observation Marcus. We can do this actually, because we can assume that captions with titles are always above the figures and left aligned, where as ones without a title are below and centered. I did the change on the Video PR as I assumed we may just use that one, since docc also combined the two features into one - 6c58c84 |
@swift-ci test |
Adds support for using the `@Image` and `@Video` directives from Tutorials in regular reference documentation. This allows authors to insert videos into documentation and to create images that have attached captions. To that point, the `@Image` and `@Video` directives can now contain inline text to form a caption. The final change here is that the `@Video` directive now supports alt text. Examples: @image( source: "overview-hero.png", alt: "An illustration of a sleeping sloth." ) { This is a caption adding additional context for the image. } @video( source: "sloth-smiling.mp4", poster: "happy-sloth-frame.png", alt: "A short video of a sloth jumping down from a branch.” ) { A *happy* sloth. 🦥 } This change is described on the Swift forums here: https://forums.swift.org/t/supporting-more-dynamic-content-in-swift-docc-reference-documentation/59527#image-1 Dependencies: - swiftlang/swift-docc-render#407 - swiftlang/swift-docc-render#404 Resolves rdar://97739628
Adds support for using the `@Image` and `@Video` directives from Tutorials in regular reference documentation. This allows authors to insert videos into documentation and to create images that have attached captions. To that point, the `@Image` and `@Video` directives can now contain inline text to form a caption. The final change here is that the `@Video` directive now supports alt text. Examples: @image( source: "overview-hero.png", alt: "An illustration of a sleeping sloth." ) { This is a caption adding additional context for the image. } @video( source: "sloth-smiling.mp4", poster: "happy-sloth-frame.png", alt: "A short video of a sloth jumping down from a branch.” ) { A *happy* sloth. 🦥 } This change is described on the Swift forums here: https://forums.swift.org/t/supporting-more-dynamic-content-in-swift-docc-reference-documentation/59527#image-1 Dependencies: - swiftlang/swift-docc-render#407 - swiftlang/swift-docc-render#404 Resolves rdar://97739628
Adds support for using the `@Image` and `@Video` directives from Tutorials in regular reference documentation. This allows authors to insert videos into documentation and to create images that have attached captions. To that point, the `@Image` and `@Video` directives can now contain inline text to form a caption. The final change here is that the `@Video` directive now supports alt text. Examples: @image(source: "overview-hero.png", alt: "An illustration of a sleeping sloth.") { This is a caption adding additional context for the image. } @video(source: "sloth-smiling.mp4", poster: "happy-sloth-frame.png", alt: "A short video of a sloth jumping down from a branch.") { A *happy* sloth. 🦥 } This change is described on the Swift forums here: https://forums.swift.org/t/supporting-more-dynamic-content-in-swift-docc-reference-documentation/59527#image-1 Dependencies: - swiftlang/swift-docc-render#407 - swiftlang/swift-docc-render#404 Resolves rdar://97739628
Adds support for using the `@Image` and `@Video` directives from Tutorials in regular reference documentation. This allows authors to insert videos into documentation and to create images that have attached captions. To that point, the `@Image` and `@Video` directives can now contain inline text to form a caption. The final change here is that the `@Video` directive now supports alt text. Examples: @image(source: "overview-hero.png", alt: "An illustration of a sleeping sloth.") { This is a caption adding additional context for the image. } @video(source: "sloth-smiling.mp4", poster: "happy-sloth-frame.png", alt: "A short video of a sloth jumping down from a branch.") { A *happy* sloth. 🦥 } This change is described on the Swift forums here: https://forums.swift.org/t/supporting-more-dynamic-content-in-swift-docc-reference-documentation/59527#image-1 Dependencies: - swiftlang/swift-docc-render#407 - swiftlang/swift-docc-render#404 Resolves rdar://97739628
Adds support for using the `@Image` and `@Video` directives from Tutorials in regular reference documentation. This allows authors to insert videos into documentation and to create images that have attached captions. To that point, the `@Image` and `@Video` directives can now contain inline text to form a caption. The final change here is that the `@Video` directive now supports alt text. Examples: @image(source: "overview-hero.png", alt: "An illustration of a sleeping sloth.") { This is a caption adding additional context for the image. } @video(source: "sloth-smiling.mp4", poster: "happy-sloth-frame.png", alt: "A short video of a sloth jumping down from a branch.") { A *happy* sloth. 🦥 } This change is described on the Swift forums here: https://forums.swift.org/t/supporting-more-dynamic-content-in-swift-docc-reference-documentation/59527#image-1 Dependencies: - swiftlang/swift-docc-render#407 - swiftlang/swift-docc-render#404 Resolves rdar://97739628
Bug/issue #, if applicable: 97715120
Summary
Extends support for the
@Image
directive, by allowing users to add captions to images.It uses the already available
InlineImage
component, and just extends theFigure
logic to wrap, if either ananchor
orabstract
is present.Dependencies
DocC PR -
Testing
You can add this RenderJSON piece to the
content
array of your render jsonprimaryContentSections
:Or use the attached JSON:
example_image.json.zip
Steps:
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
npm test
, and it succeeded