Skip to content
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 @Image and @Video directives to reference documentation with caption support #381

Merged
merged 4 commits into from
Oct 3, 2022

Conversation

ethan-kusters
Copy link
Contributor

@ethan-kusters ethan-kusters commented Sep 13, 2022

Bug/issue #, if applicable: rdar://97739628

Summary

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

Testing

Use @Image and @Video in regular article content and confirm that work as expected.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@ethan-kusters ethan-kusters changed the base branch from row-and-column to main September 14, 2022 13:26
@ethan-kusters ethan-kusters force-pushed the image-and-video branch 2 times, most recently from 57e28ad to fe0b43a Compare September 16, 2022 10:52
@ethan-kusters ethan-kusters force-pushed the image-and-video branch 3 times, most recently from a737dc5 to 01407b6 Compare October 1, 2022 09:09
@ethan-kusters ethan-kusters marked this pull request as ready for review October 1, 2022 09:11
@ethan-kusters
Copy link
Contributor Author

@swift-ci please test

@franklinsch
Copy link
Contributor

These changes look good to me. @Kyle-Ye I added you as a reviewer in case you want to take a look as well, since you've contributed to these areas in the past.

Copy link
Contributor

@Kyle-Ye Kyle-Ye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Allows for other clients of image resolving to share this logic.
Currently we resolve and diagnose image references but
include the `RenderInlineContent.image` regardless. This cleans up
that behavior to only include it in the case where the image resolves.
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
Adding support for `@Image` in regular prose
surfaced a bug in `@Volume` where the remainder
was not being properly tracked after parsing the required `@Image`
child in a `@Volume`. Instead the `@Image` stayed around in the general
prose content leading to rendering issues now that we support `@Image`
there.
@ethan-kusters
Copy link
Contributor Author

@swift-ci please test

@ethan-kusters ethan-kusters merged commit 8fb7ddd into swiftlang:main Oct 3, 2022
@ethan-kusters ethan-kusters deleted the image-and-video branch October 3, 2022 13:02
@Kyle-Ye Kyle-Ye mentioned this pull request Oct 5, 2022
3 tasks
@Kyle-Ye Kyle-Ye linked an issue Oct 5, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@Image seems to be ignored in Articles, one has to use ![]()
3 participants