Skip to content

Add the sphinx-togglebutton extension and a figure for MAP_FRAME_TYPES - #4926

Merged
seisman merged 5 commits into
masterfrom
sphinx_togglebutton
Mar 8, 2021
Merged

seisman merged 5 commits into
masterfrom
sphinx_togglebutton

Conversation

@seisman

@seisman seisman commented Mar 7, 2021 •

Copy link
Copy Markdown
Member

Description of proposed changes

This PR adds the sphinx-togglebutton extension (~20 KB) to the repository, and also an example figure for MAP_FRAME_TYPE showing how the togglebutton works.

Preview link: https://gmt-p0akp8sm5-gmt.vercel.app/gmt.conf.html#term-MAP_FRAME_TYPE

It shows a toggle button on the right:

image

Click the button, and you will see:

image

Fixes #

Reminders

  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

@maxrjones

Copy link
Copy Markdown
Member

Is the toggle button better than the dropdown directive for sphinx-panels?

@seisman

seisman commented Mar 7, 2021

Copy link
Copy Markdown
Member Author

Is the toggle button better than the dropdown directive for sphinx-panels?

I just updated the PR description.

sphinx-togglebutton provides two different styles for the toggle button (right figure). The first style (top one in the right figure) is very similar to the dropdown provided by sphinx-panels (left figure). Personally, I prefer the second style (bottom one in the right figure), because it's less distracted.

sphinx-panels sphinx-togglebutton
image image

@seisman
seisman marked this pull request as ready for review March 7, 2021 21:10

@maxrjones maxrjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@seisman

seisman commented Mar 7, 2021

Copy link
Copy Markdown
Member Author

@meghanrjones Do you still want to try the dropdown directive as you mentioned in #4743

Comment thread doc/rst/source/gmt.conf.rst Resolved
Comment thread doc/rst/source/gmt.conf.rst Resolved
Co-authored-by: Meghan Jones <[email protected]>
@maxrjones

Copy link
Copy Markdown
Member

@meghanrjones Do you still want to try the dropdown directive as you mentioned in #4743

Sure, I'll submit a PR. I think showing the code in a dropdown menu will be very helpful, but am not tied to the dropdown directive over the togglebutton extension. We can use the two PRs to compare - it will be best to be consistent throughout the documentation. Although we could also be consistent in using one option when both the figure and code are included in the dropbown and the other when the figure is static and the code is in the dropdown.

@maxrjones

maxrjones commented Mar 8, 2021 •

Copy link
Copy Markdown
Member

Regarding this comment and this reply about the toggle button hint text, I agree that we'll want to use a least two different texts for different cases. Do you think it's better to implement that in doc/rst/_extensions or submit a feature request to sphinx-togglebutton for extending the directive to support a custom hint text?

@seisman

seisman commented Mar 8, 2021

Copy link
Copy Markdown
Member Author

Regarding this comment and this reply about the toggle button hint text, I agree that we'll want to use a least two different texts for different cases. Do you think it's better to implement that in doc/rst/_extensions or submit a feature request to sphinx-togglebutton for extending the directive to support a custom hint text?

I think we can add it here first, and submit a feature request later. It's unclear to me if they like this feature and how often they made a release.

@seisman

seisman commented Mar 8, 2021

Copy link
Copy Markdown
Member Author

@meghanrjones I'd like to merge this PR into master first and work on the "custom hint text" in a separate PR. I feel that it's easier to track the changes and submit a PR to upstream.

@maxrjones

Copy link
Copy Markdown
Member

@meghanrjones I'd like to merge this PR into master first and work on the "custom hint text" in a separate PR. I feel that it's easier to track the changes and submit a PR to upstream.

Yes, I agree.

@seisman
seisman merged commit 2dbd940 into master Mar 8, 2021
@seisman
seisman deleted the sphinx_togglebutton branch March 8, 2021 19:29
@seisman

seisman commented Mar 8, 2021

Copy link
Copy Markdown
Member Author

Just had a quick look at the sphinx-togglebutton source codes, it looks difficult to support "custom hint text", because the hint text is controlled by CSS.

I'll open a feature request later. Perhaps we can use "Click to show the source or an example" as a temporary workaround.

This branch was previously deployed

1 inactive deployment
Preview — 6d6cd2eb Deployed Mar 7, 2021 by vercel[bot]
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