Skip to content

Add support for @Video directive #407

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

Conversation

dobromir-hristov
Copy link
Contributor

@dobromir-hristov dobromir-hristov commented Aug 9, 2022

Bug/issue #, if applicable: 97715316

Summary

Add support for DocC @Video directive in Documentation pages.

image

Dependencies

This PR extends the work done the PRs below, and should be rebased after they are merged into main.

#404
#406

DocC PR - swiftlang/swift-docc#381

Testing

We need proper DocC support to be able to test this out, but you can add this JSON to the content of a random RenderJSON file from a doccarchive, and it should work:

Video JSON

                {
                  "type": "video",
                  "identifier": "video-reference.mp4",
                  "metadata": {
                    "abstract": [
                      {
                        "type": "text",
                        "text": "Video Caption"
                      }
                    ]
                  }
                }

Reference JSON inside references

    "video-reference.mp4": {
      "poster": "reference-to-poster-image",
      "type": "video",
      "identifier": "video-reference.mp4",
      "alt": null,
      "variants": [
        {
          "traits": [
            "1x",
            "light"
          ],
          "url": "/path/to/video.mp4"
        },
        {
          "traits": [
            "1x",
            "dark"
          ],
          "url": "/path/to/video~dark.mp4"
        }
      ]
    }

Steps:

  1. Assert a replayable video is rendered with a "Play" button beneath it.
  2. Assert Video can be rendered with a caption below it, but also without.

Checklist

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

  • Added tests
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

Copy link
Contributor

@mportiz08 mportiz08 left a comment

Choose a reason for hiding this comment

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

I think we should mark this PR as a draft until the two dependent PRs have been merged, and this has been rebased.

@dobromir-hristov
Copy link
Contributor Author

I think we should mark this PR as a draft until the two dependent PRs have been merged, and this has been rebased.

Yes, I just wanted to get things rolling.

@dobromir-hristov dobromir-hristov marked this pull request as draft August 11, 2022 05:51
@dobromir-hristov dobromir-hristov force-pushed the dhristov/r97715316-add-inline-video-support branch from e776478 to ccd67d2 Compare September 12, 2022 09:17
@dobromir-hristov dobromir-hristov marked this pull request as ready for review September 14, 2022 09:02
@dobromir-hristov
Copy link
Contributor Author

@swift-ci test

1 similar comment
@dobromir-hristov
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@mportiz08 mportiz08 left a comment

Choose a reason for hiding this comment

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

Looks good and is working with the DocC branch.

My only minor concern is that the "Play" icon is the same icon as the "Replay" icon, which is a little bit odd. I would probably actually prefer that we just use the normal video controls and remove the play/replay link entirely, but you may want to discuss with the design team.

Also, make sure to rebase this against the main branch once the 3 dependent PRs have been merged (the replay one, the image one, and the figure caption one) before merging this one.

@dobromir-hristov dobromir-hristov force-pushed the dhristov/r97715316-add-inline-video-support branch from 95cabaf to 05e58d3 Compare September 15, 2022 06:56
@dobromir-hristov
Copy link
Contributor Author

@swift-ci test

@dobromir-hristov
Copy link
Contributor Author

My only minor concern is that the "Play" icon is the same icon as the "Replay" icon

You have a point Marcus, I changed that because it's a good point anyway.

image

I will check with Design if they want me to just show full native controls all the time, instead of just on mobile devices. I think we discussed that we may want just the minimal UI of the tutorials.

@dobromir-hristov
Copy link
Contributor Author

@swift-ci test

Dobromir Hristov added 2 commits September 15, 2022 11:11
# Conflicts:
#	src/components/ContentNode.vue
#	tests/unit/components/ContentNode.spec.js
@dobromir-hristov
Copy link
Contributor Author

@swift-ci test

@dobromir-hristov
Copy link
Contributor Author

@swift-ci test

@dobromir-hristov dobromir-hristov merged commit 3283805 into swiftlang:main Sep 15, 2022
@dobromir-hristov dobromir-hristov deleted the dhristov/r97715316-add-inline-video-support branch September 15, 2022 14:24
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Sep 30, 2022
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
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Sep 30, 2022
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
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Oct 1, 2022
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
ethan-kusters added a commit to ethan-kusters/swift-docc that referenced this pull request Oct 3, 2022
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
ethan-kusters added a commit to swiftlang/swift-docc that referenced this pull request Oct 3, 2022
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
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.

3 participants