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

DOCS: Add example directive #550

Merged
merged 10 commits into from
May 16, 2022

Conversation

choldgraf
Copy link
Member

This is a lightweight directive that lets you write some source markdown, and displays the "raw" and "rendered" version of the text so that others can learn from it. It is meant to make it easier to quickly write demonstration content without needing a ton of duplicates in your code.

I started it off in this repository so that we can use it in Jupyter Book, but if others find it useful we could port it into a standalone extension.

@chrisjsewell
Copy link
Member

Hmm, it's up to you, but I don't really think here is the right place for this. Also to note, I've done something similar in https://sphinx-design.readthedocs.io/en/latest/tabs.html#tabbed-code-examples

@choldgraf
Copy link
Member Author

this one is purely for convenience sake - I agree it's better someplace else in general, but the code is quite simple so I just wanted something quick for now that I could use as part of the sphinx-design refactor.

Maybe instead of having it in the book theme I can just hard-code something in the docs of jupyter-book to re-use, so that it's clearer this isn't meant for a long-term home. I just don't have time to create a new sphinx extension from scratch right now.

Longer term, maybe we create a sphinx-demo extension or something? I like the tabbed example as well - though would prefer something that shows both the source and the result without requiring user to click between them

@choldgraf
Copy link
Member Author

choldgraf commented Apr 24, 2022

Random idea - what about putting this in sphinx-design? I'd be fine bringing this functionality as an "extra" in sphinx-design - so long as we can have examples that show both the source and the result at the same time, without being hidden behind tabs or dropdowns.

I actually think the implementation could be a bit nicer if we used the SD {grid} directive anyway. That said, I don't have many cycles to work on this and don't want it to block the sphinx-design update in jupyter book, so may just do a hacky thing now

@choldgraf
Copy link
Member Author

choldgraf commented Apr 27, 2022

I thought about @chrisjsewell's suggestion and decided to turn this into a lightweight python package that could be re-used and developed on its own. That now lives at the address below:

https://github.com/executablebooks/sphinx-examples

This PR is now re-worked to re-use that package in our documentation. It currently loads sphinx-examples from the GitHub repo ZIP file just to preview and iterate on it, but we can make a release and use the version on pypi before merging here.

@choldgraf choldgraf changed the title NEW: Add example directive DOCS: Add example directive May 16, 2022
@choldgraf choldgraf merged commit 8a24592 into executablebooks:master May 16, 2022
@choldgraf choldgraf deleted the example-directive branch May 16, 2022 13:53
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.

2 participants