diff --git a/adi_doctools/__init__.py b/adi_doctools/__init__.py index 960e25a..979adce 100644 --- a/adi_doctools/__init__.py +++ b/adi_doctools/__init__.py @@ -11,7 +11,7 @@ from .role import setup as role_setup from .lut import get_lut -__version__ = "0.3.41" +__version__ = "0.3.42" logger = logging.getLogger(__name__) diff --git a/adi_doctools/directive/common.py b/adi_doctools/directive/common.py index 6ceec72..1ea5caf 100644 --- a/adi_doctools/directive/common.py +++ b/adi_doctools/directive/common.py @@ -10,7 +10,7 @@ from hashlib import sha1 from typing import Tuple -from .node import node_div, node_input, node_label, node_icon, node_source +from .node import node_div, node_input, node_label, node_icon, node_source, node_a from .node import node_iframe, node_video logger = logging.getLogger(__name__) @@ -245,13 +245,17 @@ def run(self): ) yt_id = yt_match.group(3) iframe = node_iframe( - src=f"https://www.youtube-nocookie.com/embed/{yt_id}" + src=f"https://www.youtube-nocookie.com/embed/{yt_id}", + classes=['only-screen'] ) node += iframe else: - node = node_div() + node = node_div( + classes=['embed-video'] + ) video = node_video( - controls="controls" + controls="controls", + classes=['only-screen'] ) source = node_source( type="video/mp4", @@ -260,6 +264,30 @@ def run(self): video += source node += video + node_ = nodes.inline( + classes=['only-screen'] + ) + self.state.nested_parse(self.content, self.content_offset, node_) + node += node_ + + # Generate a video admonition for print + adm = node_div( + classes=['admonition', 'video', 'only-print'] + ) + adm += nodes.paragraph( + text="Video", + classes=["admonition-title"] + ) + + video_link = node_a(href=url) + video_link += nodes.inline(text=url) + + self.state.nested_parse(self.content, self.content_offset, adm) + node_ = nodes.paragraph() + node_ += video_link + adm += node_ + node += adm + return [node] diff --git a/adi_doctools/directive/node.py b/adi_doctools/directive/node.py index 43f488d..18ec54c 100644 --- a/adi_doctools/directive/node.py +++ b/adi_doctools/directive/node.py @@ -57,8 +57,12 @@ class node_iframe(node_base): tagname = 'iframe' endtag = 'false' +class node_a(node_base): + tagname = 'a' + endtag = 'true' + def node_setup(app): - for node in [node_div, node_input, node_label, node_icon, node_video, node_source, node_iframe]: + for node in [node_div, node_input, node_label, node_icon, node_video, node_source, node_iframe, node_a]: app.add_node(node, html =(node.visit, node.depart), latex=(node.visit, node.depart), diff --git a/adi_doctools/theme/cosmic/style/bundle.scss b/adi_doctools/theme/cosmic/style/bundle.scss index a82ea3a..23e1023 100644 --- a/adi_doctools/theme/cosmic/style/bundle.scss +++ b/adi_doctools/theme/cosmic/style/bundle.scss @@ -10,3 +10,4 @@ @import "footer"; @import "related"; @import "code"; +@import "print"; diff --git a/adi_doctools/theme/cosmic/style/collapsible.scss b/adi_doctools/theme/cosmic/style/collapsible.scss index b4d6ff7..cfced6b 100644 --- a/adi_doctools/theme/cosmic/style/collapsible.scss +++ b/adi_doctools/theme/cosmic/style/collapsible.scss @@ -6,13 +6,52 @@ .collapsible_content { overflow: auto; - border-top: $border-panel; overflow: hidden; - height: 0; transition: ease opacity .25s; - opacity: 0; } +@media not print { + .collapsible_content { + height: 0; + opacity: 0; + } + + .collapsible { + border: $border-panel; + margin-bottom: .5em; + + label { + padding: 0.75em 1em 0.75em .75em; + } + + label .icon { + display: block; + } + + table.docutils { + border: none; + width: 100%; + } + } + + .collapsible_content { + border-top: $border-panel; + } +} + +@media print { + .collapsible { + label { + padding: 0.5em 0 0.5em 0; + } + + label .icon { + display: none; + } + } +} + + .collapsible_input:checked ~ label .icon { transform: rotate(45deg); margin-top: -.5em; @@ -24,17 +63,10 @@ } .collapsible { - border: $border-panel; border-radius: .25em; - margin-bottom: .5em; - - .collapsible { - margin: .25em; - } label { width: 100%; - padding: 0.75em 1em 0.75em .75em; user-select: none; box-sizing: border-box; cursor: pointer; @@ -46,7 +78,6 @@ label .icon { border: 1px solid var(--text-color1); border-width: 0 2px 2px 0; - display: block; transition: transform ease .125s, margin-top ease .125s; width: .6em; height: .6em; @@ -72,11 +103,6 @@ font-weight: 600; } - table.docutils { - border: none; - width: 100%; - } - .container > p { margin-left: .5em; margin-right: .5em; diff --git a/adi_doctools/theme/cosmic/style/element.scss b/adi_doctools/theme/cosmic/style/element.scss index d56ea5b..db84e78 100644 --- a/adi_doctools/theme/cosmic/style/element.scss +++ b/adi_doctools/theme/cosmic/style/element.scss @@ -122,7 +122,7 @@ img { max-width: 100%; } -@media (min-width: $width-narrow) { +@media (min-width: $width-content) { .body img { display: block; margin: 0 auto; @@ -192,6 +192,12 @@ iframe { border: none; } +@media screen { + .iframe-video p, .embed-video p { + text-align: center; + } +} + .iframe-video { iframe { box-shadow: $box-shadow-raised; diff --git a/adi_doctools/theme/cosmic/style/footer.scss b/adi_doctools/theme/cosmic/style/footer.scss index 8c40c03..ede35dd 100644 --- a/adi_doctools/theme/cosmic/style/footer.scss +++ b/adi_doctools/theme/cosmic/style/footer.scss @@ -1,9 +1,13 @@ footer { - background: var(--bg-color1); border-top: $border-panel; padding: 1em; } +@media screen { + footer { + background: var(--bg-color1); + } +} @media (min-width: $width-narrow) { footer { diff --git a/adi_doctools/theme/cosmic/style/header.scss b/adi_doctools/theme/cosmic/style/header.scss index be03f77..24b7a67 100644 --- a/adi_doctools/theme/cosmic/style/header.scss +++ b/adi_doctools/theme/cosmic/style/header.scss @@ -25,7 +25,6 @@ header { z-index: 7; position: sticky; width: 100%; - border-bottom: $border-panel; top: 0; label, button { @@ -80,6 +79,12 @@ header { } } +@media screen { + header { + border-bottom: $border-panel; + } +} + .repotoc-tree.overlay { position: sticky; top: 3.5rem; @@ -151,11 +156,23 @@ header { } @media (max-width: $width-narrow) { + @media screen { + header { + border-bottom: $border-panel; + } + } + header { display: flex; width: 100%; - border-bottom: $border-panel; - background: var(--bg-color1-faded1); + } +} + +@media screen { + @media (max-width: $width-narrow) { + header { + background: var(--bg-color1-faded1); + } } } diff --git a/adi_doctools/theme/cosmic/style/mixin_admonition.scss b/adi_doctools/theme/cosmic/style/mixin_admonition.scss index 4edb944..ce4724a 100644 --- a/adi_doctools/theme/cosmic/style/mixin_admonition.scss +++ b/adi_doctools/theme/cosmic/style/mixin_admonition.scss @@ -10,8 +10,9 @@ $admonitions: ( "tip": #00c852 "info", "important": #00bfa5 "flame", "note": #00b0ff "pencil", + "video": #00b0ff "video", "seealso": #448aff "info", - "admonition-todo": #808080 "pencil" + "admonition-todo": #808080 "pencil", ); @mixin default-admonition($color, $icon-name) { diff --git a/adi_doctools/theme/cosmic/style/mixin_icons.scss b/adi_doctools/theme/cosmic/style/mixin_icons.scss index 8edbbaf..a401b82 100644 --- a/adi_doctools/theme/cosmic/style/mixin_icons.scss +++ b/adi_doctools/theme/cosmic/style/mixin_icons.scss @@ -29,6 +29,8 @@ $icons: ( // Custom icons "adi": url('data:image/svg+xml;charset=utf-8,'), + "video": + url('data:image/svg+xml;charset=utf-8,'), "ez": url('data:image/svg+xml;charset=utf-8,'), "external": diff --git a/adi_doctools/theme/cosmic/style/print.scss b/adi_doctools/theme/cosmic/style/print.scss new file mode 100644 index 0000000..1016366 --- /dev/null +++ b/adi_doctools/theme/cosmic/style/print.scss @@ -0,0 +1,25 @@ +@media not print { + .only-print { + display: none !important; + } +} + +@media print { + .only-screen { + display: none !important; + } + + header #left, header .reverse { + display: none !important; + } + + body.light .highlight { + background: none; + border: 1px solid var(--text-color3); + } + + .body { + padding: 0; + } + +} diff --git a/adi_doctools/theme/cosmic/style/style.scss b/adi_doctools/theme/cosmic/style/style.scss index 1f44b69..e5034dd 100644 --- a/adi_doctools/theme/cosmic/style/style.scss +++ b/adi_doctools/theme/cosmic/style/style.scss @@ -81,11 +81,16 @@ body.dark { body { margin: 0; - background-color: var(--bg-color1); color: var(--text-color1); overflow-x: hidden; } +@media screen { + body { + background-color: var(--bg-color1); + } +} + * { box-sizing: border-box; } @@ -158,7 +163,7 @@ svg { margin: 0 auto; } -@media (min-width: $width-narrow) { +@media (min-width: $width-content) { #hdl-component-diagram svg { float: right; margin: -3em 0 0 1em; diff --git a/adi_doctools/theme/cosmic/style/variable.scss b/adi_doctools/theme/cosmic/style/variable.scss index 6978edc..bd1874a 100644 --- a/adi_doctools/theme/cosmic/style/variable.scss +++ b/adi_doctools/theme/cosmic/style/variable.scss @@ -26,4 +26,5 @@ $border-radius: .25em; $width-wide: 105em; $width-narrow: 85em; +$width-content: 60em; $width-narrowest: 40em; diff --git a/docs/docs_guidelines.rst b/docs/docs_guidelines.rst index 827a373..744d6b5 100644 --- a/docs/docs_guidelines.rst +++ b/docs/docs_guidelines.rst @@ -745,26 +745,39 @@ The directive syntax is: .. video:: + + +Always add a caption to the video, since a PDF output won't contain the embed +video, but a link to it. + For example: .. code:: rst .. video:: http://ftp.fau.de/fosdem/2015/devroom-software_defined_radio/iiosdr.mp4 + **Linux Industrial IO framework** - Lars-Peter Clausen, Analog Devices Inc + Renders as: .. video:: http://ftp.fau.de/fosdem/2015/devroom-software_defined_radio/iiosdr.mp4 + **Linux Industrial IO framework** - Lars-Peter Clausen, Analog Devices Inc + And: .. code:: rst .. video:: https://www.youtube.com/watch?v=p_VntEwUe24 + **LibIIO - A Library for Interfacing with Linux IIO Devices** - Dan Nechita, Analog Devices Inc + Renders as: .. video:: https://www.youtube.com/watch?v=p_VntEwUe24 + **LibIIO - A Library for Interfacing with Linux IIO Devices** - Dan Nechita, Analog Devices Inc + ESD warning directive ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~