Skip to content

Conversation

steppi
Copy link
Collaborator

@steppi steppi commented Jan 26, 2024

Closes #122, #127

This PR updates TryExamplesDirective to use the standard method of allowing custom css in Sphinx to customize the buttons as suggested by Carreau here. It also adds customization of min_height to the config file try_examples.json so that the minimum height can bet changed at runtime. An option has been given to the directive to set the specific height of the iframe container for the embedded notebook and the min_height option has been removed. The specific height overrides the minimum height set in try_examples.json. I've also attempted to improve the documentation, and have added an example_class option to the directive which can be targeted in custom css as suggested by Carreau.

@steppi steppi added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 26, 2024
.try_examples_button_container {
display: flex;
justify-content: flex-end;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Thanks for your patience on the review, I'm just back from PTO.

@@ -28,4 +28,7 @@
]
}

html_static_path = ["_static"]
html_css_files = ["try_examples.css"]

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

display: flex;
justify-content: flex-end;
}
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -184,23 +224,38 @@ directory of the build directory for the deployed documentation. The format is a
`TryExamples` buttons will be hidden in url pathnames matching at least one of these
patterns, effectively disabling the interactive documentation. In the provided example:

* The pattern `".*latest/.*" disables interactive examples for urls for the documentation
* The pattern `"^/latest/.*"` disables interactive examples for urls for the documentation
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch.

"button_horizontal_position": directives.unchanged,
"button_vertical_position": directives.unchanged,
"min_height": directives.unchanged,
"example_class": directives.unchanged,
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

f" 'top' or 'bottom', received {button_vertical_position}."
)
height = self.options.pop("height", None)
example_class = self.options.pop("example_class", "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a fix for this PR, but do we want to check here that example_class is a valid class name ? (no space, no dots, no /\ or angle brackets for example) as we do inject it with fstrings it might break the html/css otherwise

"try_examples_default_runtime_config",
default=None,
rebuild=None,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I love when a bunch of lines get deleted.

@Carreau
Copy link
Collaborator

Carreau commented Jan 31, 2024

Ok, let's get that in. I'll open an issue to think about validating the height and example_class

@steppi
Copy link
Collaborator Author

steppi commented Jan 31, 2024

Thanks @Carreau!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rework the order of "try-example" documentation
2 participants