Coder Social home page Coder Social logo

executablebooks / sphinx-book-theme Goto Github PK

View Code? Open in Web Editor NEW
400.0 13.0 193.0 2.4 MB

A clean book theme for scientific explanations and documentation with Sphinx

Home Page: https://sphinx-book-theme.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Python 18.69% HTML 11.94% JavaScript 2.32% Makefile 0.40% Jupyter Notebook 58.45% SCSS 8.21%
sphinx-theme

sphinx-book-theme's People

Contributors

aakashgfude avatar afeld avatar agoose77 avatar akhmerov avatar bknaepen avatar bollwyvl avatar callezenwaka avatar calmaccq avatar chokkan avatar choldgraf avatar chrisjsewell avatar dependabot[bot] avatar dfm avatar dmwyatt avatar drdrij avatar flying-sheep avatar fmaussion avatar foster999 avatar joergbrech avatar kousu avatar lewtun avatar mmcky avatar najuzilu avatar nathancarter avatar ogrisel avatar patrickmineault avatar pradyunsg avatar pre-commit-ci[bot] avatar rossbar avatar zedthree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sphinx-book-theme's Issues

Add styling to executed outputs

I think it might be helpful to add styling around executed outputs - maybe a cell that looks like the code input but lighter? I'm open to other ideas.

Also, some of the executed outputs are aligned in the middle. I think they should be aligned to the left, similar to the rest of the executed outputs.
Screen Shot 2020-03-30 at 2 59 09 PM

:align: center does not work for images

Describe the bug

When using :align: center with images (SVG) from a jupyter-book document (myst source file), the image remains aligned to the left.

I am able to overcome this by adding the following to my custom.css:

img.align-center {
   margin-left: auto;
   margin-right: auto;
   text-align:center;
   display:block;
}

I don't fully understand why this solution works, so I'm reluctant to submit it as a PR.

Environment
jupyter-book 0.7.3
Sphinx 2.4.4
sphinx-book-theme 0.0.33
sphinx-bootstrap-theme 0.7.1
sphinx-copybutton 0.2.11
sphinx-rtd-theme 0.4.3
sphinx-thebe 0.0.7
sphinx-togglebutton 0.2.0

Installation instructions?

You don't actually mention anywhere (in the docs or README) that its pip install sphinx-book-theme and html_theme = "sphinx_book_theme"!

Add the ability to have spacers etc somehow in the left TOC

Is it possible to include things that aren't links in the TOC? we should figure that out...

This could probably be done by:

Make left sidebar into an off-canvas drawer on mobile/tablet

Is your feature request related to a problem? Please describe.

  • The (left) sidebar "comes in from the top" of the page, through resizing of the corresponding element. This implementation requires JS to work [^1] and shows up in a different place than the desktop sidebar.
  • The (left) sidebar does not degrade gracefully when JS is disabled. A user who has JS disabled for some reason (ahem like me) cannot view documentation built with this theme on mobile, since the sidebar cannot be collapsed and covers regular content. And they can't access the navigation either.

A link to the documentation page where you see an issue.

Any page works TBH. Here's the page I have open right now: https://sphinx-book-theme.readthedocs.io/en/latest/index.html

Describe the solution you'd like

I suggest we switch to the same mechanism+design for providing the sidebar as the mkdocs-material theme: https://squidfunk.github.io/mkdocs-material/getting-started/. Try it on ~1024px wide windows, which shows how it works best IMO. That mechanism works without needing JS (it's pure-CSS) and, thus, degrades gracefully.

Note that I'm not suggesting we change the contents/design of what's in the sidebar in this issue, but only how it is handled in terms of being visible/not visible.

FWIW, I have experience with implementing this style of a sidebar, from when I was working on re-implementing mkdocs-material for Sphinx here. I'm happy to try re-implementing it in the context of this theme, if there's interest in making this switch.

Document how to work on this project

Is your feature request related to a problem? Please describe.

It is currently unclear to me (someone new to the project!) what I should do to work on this theme, and what workflows are for the various tasks related to the project.

A link to the documentation page where you see an issue.

N/A

Describe the solution you'd like

A clear "Development/Getting Started" guide (like https://pip.pypa.io/en/latest/development/getting-started/) that describes how to setup a development environment, and how to do common development workflow tasks -- namely running the code, generating the documentation, running linters, running the tests.

I suggest using something like nox, to simplify the workflow tasks even further, to be "run nox -s <name>". Being able to do nox -s lint / nox -s docs / nox -s tests and having it manage setting up the environments, would be great. Once I figure out what the setups look like, I'd be happy to file a PR adding a nox configuration for this project, if it would be welcome. :)

TypeError("'NoneType' object is not callable")

Since yesterday, my documentation has been broken with the following error:

writing output... [ 14%] api/modules
Theme error:
An error happened in rendering the page api/modules.
Reason: TypeError("'NoneType' object is not callable")
make: *** [html] Error 2

It's in the templated API page, but that used to work and works in RtD's theme. Forcing the version to 0.0.30 solves the issue. It's in boost-histogram.readthedocs.io / GitHub.com/scikit-hep/boost-histogram.

Edit this page warning doesn't make sense

It asks for github_version in html_context but really needs to be repository_branch. Also should probably just default to master.

Also, path to docs should just default to the Sphinx docs build folder

Support non-github repositories

Description

We currently only support GitHub repositories for "repository link" as well as "edit this page". We should support a few of the more common ones as well, such as bitbucket and gitlab.

Here are major repository-specific features we'd want to implement:

  • Repository link / issues link
  • Edit this page link
  • Launch buttons link

Benefit

This would make these theme features usable for people that use these other (quite popular) platforms!

Implementation details

Repository link

For the repository link, here's our code (and likely where a fix would be):

https://github.com/executablebooks/sphinx-book-theme/blob/master/sphinx_book_theme/topbar/repobuttons.html

Edit this page link

We seem to be using the PyData Sphinx Theme get_edit_url function for this already, so we should figure out how to make it support non-GitHub repositories:

{% if theme_use_edit_page_button %}<a class="edit-button" href="{{ get_edit_url() }}"><button
type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip" data-placement="left"
title="{{ translate('Edit this page') }}"><i class="fas fa-pencil-alt"></i>{{ translate('suggest edit') }}</button></a>{% endif %}
</div>

here's the PyData theme function for this:

https://github.com/pydata/pydata-sphinx-theme/blob/055ae27cdc6801d6abba0c43bfa9cfd3a359e1b9/pydata_sphinx_theme/__init__.py#L481

launch buttons

Here's the templating for our launch buttons:

https://github.com/executablebooks/sphinx-book-theme/blob/master/sphinx_book_theme/topbar/launchbuttons.html

And the Python logic that handles how we build these buttons:

https://github.com/executablebooks/sphinx-book-theme/blob/master/sphinx_book_theme/launch.py

Maybe we can re-use the get_edit_url for this somehow as well.

This would require changes here and here.

In particular raw git remotes should cover a lot of use cases.

Design: Don't use different font size for sidebar content

Is your feature request related to a problem? Please describe.

Font sizing changes in the sidebars make it difficult to read/skim the sidebar's contents and well as make it look out-of-place.

Describe the solution you'd like

Use the same size as the content for all navigation items in both sidebars.

  • The indentation is sufficient to make the "depth" clear.
  • Whitespace + bold text can be used for captions and toctrees to separate them visually.

See readme.com's design for inspiration/idea.

Describe alternatives you've considered

I can't think of any good ones. :)

Additional context

I'm happy to try implementing this myself, if there's interest in this idea. :)

Improvements to single page

Per some comments from @chrisjsewell we should add:

  • Less whitespace to the left in single page mode (closed by #104)
  • The option to keep the TOC present at all times (now in #102) closed by #103

(longer term we can try to find a way to put the TOC in the left sidebar, but for this will at least improve things for now)

Use beautifulsoup for testing

In many of the tests we are just seeing if some text made it into the HTML at all. That usually works, but it'd be better to zero-in on the specific part of the page we want to test and use beautifulsoup to confirm what is in there

Discuss how the theme should link out to external sites

In a conversation with @ericvd-ucb he brought up a use-case I have heard many others mention as well, which is that they'd like to have a website that hosts multiple books, and want some way to link between books on their site. This is an issue to figure out that use-case.

Two options I can think of:

  • Make it easy to add extra links to the book's navigation in the sidebar. Maybe with a specific configuration value, or a way to parse toc.yml to find this.
  • Make it possible to add a top-bar (similar to the pydata one?) that can link between books or other external pages.

Design: (right sidebar) Change "On this page" to "Contents" (or "Table of Contents")

Describe the changes you'd like

Title says it all.

Describe alternatives you've considered

None. Status quo is OK. Suggested change is nicer, but I'm obviously biased. :)

Additional context

This seems to be the phrasing for the in-page-navigation-tree on all 3-column documentation-oriented themes that I know of (except this theme and the pydata theme). Sample Screenshots: https://gist.github.com/pradyunsg/eeb74ac5b580d502c3d0e248310f273f

I'm happy to file a PR for this, if there's interest in this idea. :)

"On this page" menu not working in Safari

(migrating from #80)

In Safari, bringing your cursor over "On this page" results in the menu appearing and then disappearing, before one has a chance to click on anything (or read it really). On Firefox, it seems to have the desired behavior (menu appearing when highlighted, staying until you click or move elsewhere).

Make the right TOC hidden by choice

Currently the right TOC will hide itself when you scroll down the page, but this probably doesn't make sense for Sphinx themes which generally don't use the right margin as much (as opposed to Jupyter Books which may use this more).

We should either:

  1. Make the "hiding" functionality of the right toctree and option
  2. Only make the right toctree hide on scroll if there is margin content on the page

Add a shadow to the top bar on scroll

Is your feature request related to a problem? Please describe.

Content at the top of the page gets cropped, seemingly for no reason.

Describe the solution you'd like

A shadow underneath the top bar would make it easier to perceive that there is an element that's supposed to be on top, making it clearer why content is getting cropped (there's something above it!).

Describe alternatives you've considered

None.

Additional context

See https://squidfunk.github.io/mkdocs-material/getting-started/ for a decent+subtle implementation of this.

Book menu incorrectly displayed in iPad

Describe the bug
I have noticed a bug when navigating the following url from an iPad: https://jupyterbook.org/intro.html.

The menu is displayed like grayed/transparent on top of the text, and it doesn't look good at all.

To Reproduce
You may navigate to the url above from an iPad, or just use chrome developer tools and select iPad.

I have copied below a screenshot showcasing the issue and how to reproduce it.

Screenshot 2020-05-27 at 16 36 19

Hope it helps!

Improve CSS / JS for citations

It would be great if we had hover-style citations similar to how Distill does citations (example). When a user hovers over a citation, a short pop-up shows the reference for that citation.

I wonder if that's something that could be shared between @rowanc1's projects and jupyter book? Even better if we could upstream this to sphinxcontrib-bibtex.

Maybe there is a <citation> web component that is becoming a standard these days?

Permit Colab links in addition to or instead of Binder links

It is nice and easy to turn any Jupyter notebook on GitHub into an executable one on Colab by simply visiting any URL of the form https://colab.research.google.com/github/USER/REPO/blob/master/PATH/FILENAME.ipynb. This is often more desirable than Binder because of the much faster load time of the Colab environment than the Binder one, and of course the ability to save your own copies of notebooks. Could this be an option in jupyter-book, at least for those books published to GitHub?

How to get the same look and feel than Pandas doc theme?

Hi!

First of all, I would like to congratulate all of you for the great work done with this theme. It looks great!

I have read that, somehow, it is inspired in Pandas theme, used here: https://pandas.pydata.org/pandas-docs/stable/

I personally like a bit more Pandas theme than the current proposal from jupyterbook, and I was wondering how difficult is to have the same theme as Pandas, if possible.

Any guidance about how to get it done would be welcomed!

In the meanwhile, have an awesome day!

Regars,
Miguel

Discuss spacing / crowding issues

We've made a few changes lately that I think make the theme more a11y-friendly, which is good. Though they also seem to have crowded things a bit when there is a lot of text on the screen. For example, here's what the EBP contributing page looks like in this theme:

New version
image

Old version
image

Maybe this is just me, but it feels more "crowded" and text-heavy now. I'm not sure what's the best way to improve this ๐Ÿค” maybe @pradyunsg has thoughts

Design: Tweaking bottom-of-page content/structure

This is intended to initiate a discussion, to gauge whether there's anyone else who feels such a change would be useful as well as figure out what we'd change to. :)

Describe the change you'd like

Multiple changes to the design of the bottom-of-page in this theme:

  • Add a bit of space to separate "content" from "footer"
  • Change the content in the footer (making it similar to the left half of mkdocs-material's bottom-of-page)
    • Move "Theme by the Executable Book Project" out of the left sidebar, into the footer
      • This is a more visible spot, and it's still out-of-the-way enough :)
    • Tweak the copyright line to match what most other documentations themes do
      • "Copyright ยฉ 2020 <project name>"
  • Change how the next/previous links look
    • Swap "<<" and ">>" for proper arrows
    • Limit width to the content (instead of overflowing into right sidebar's region)
    • Tweak style to be a middle-ground between what GitBook and mkdocs-material do
      • 50% width for both "next and prev" (like GitBook)
      • Align text to be closer to the arrows (like mkdocs-material, maybe?)
      • No visual border around the element, but a general region around the text works (like mkdocs-material, maybe?)

Additional Context

(screenshot of current bottom of page)
Screenshot 2020-08-06 at 10 28 11 AM

(screenshot) GitBook's bottom-of-page:
Screenshot 2020-08-06 at 10 27 35 AM

(screenshot) mkdocs-material's bottom-of-page:
Screenshot 2020-08-06 at 10 30 42 AM

readme.com's bottom-of-page (screenshot, click to view) Screenshot 2020-08-06 at 10 31 41 AM

Top-of-page screenshots and links to the corresponding pages: https://gist.github.com/pradyunsg/eeb74ac5b580d502c3d0e248310f273f

Figure out how to make the middle content grow automatically

A few attempts at making the middle "main content" section grow automatically haven't worked, because it expands to fill the extra space due to the wide elements inside of it. We should figure out how to get around this, so that we only need to define the width of the left and right sidebar, and have the middle column automatically expand

Support thebelab's predefined output

One of the important use cases for incorporating thebelab into a project is to allow tweaking already existing outputs. Out of the box, IIUC the already computed outputs would be duplicated by whatever thebelab produces.

At the same time, thebelab supports specifying predefined arguments, which are made into cell outputs as soon as thebelab is activated, see the required config here.

This would require modifying thebelab configuration, as well as ensuring that DOM is appropriate (the outputs must be in a div that directly follows the input).

Collapsible ToC headings

I propose to allow making some toc sections collapsible and collapsed by default.

While the default works well, collapsible toc sections would be potentially useful for appendices/exercise solutions (my personal use case)/bonus chapters.

Edit: readme.com has a good example of collapsing entries in the section-pages-tree (left sidebar):

Downloading .ipynb results in a .ipynb.txt file

In my book as well as in the documentation if you click to download the source of a jupyter notebook in the upper right button, it seems to add a .txt extension to the .ipynb file. I'm not sure if this is by design or a bug, I looked quickly and could not find it documented.

In the same documentation, there is a html link: "you can download the notebook content for this page." that results in downloading a notebook file (.ipynb) fine.

Relation between sphinx-book-theme and Jupyter Book?

Hi guys!

This is very cool what you are building! ๐Ÿ™‚ I was wondering that how do you see the future of sphinx-book-theme? I.e. is the idea to eventually support all the same functionalities that Jupyter Book has now or how are these projects related?

We are writing a book with my colleagues and originally we have been using Sphinx to build all our materials. Then we found Jupyter Book and seriously started thinking switching to that one because of many cool features (such as the interactive code cells with Thebelab). I was already playing around with the JupyterBook a bit and configuring the pages with RTD (not very straightforward..), and then I found this theme! So again I am wondering that should we stick with Sphinx and wait this project to develop.. ๐Ÿ˜„

@choldgraf

Add support for JupyterHubs as well as Thebelab

Admonitions: why icons after not before?

Is there a reasoning for this? Don't know if I like it ๐Ÿ˜ฌ

image

I say this because I've been playing around with overriding the RTD theme admonition icon with custom ones for different semantic content e.g.

.title-icon-troubleshoot .admonition-title:before {
    margin-right:.5rem;
    content: "\f0ad"  /* wrench */
}
.title-icon-read-more .admonition-title:before {
    margin-right:.5rem;
    content: "\f08e"  /* external-link */
}
.. admonition:: Having problems?
    :class: attention title-icon-troubleshoot

   ...

image

I don't think this would look as nice with icons after.

Support non-github repositories

This is a continuation from #114, following #118.

Several places now hard-code github-specific information. For example #118 introduces the github icon in the top bar, and the schema for pre-populating issue with parameters.

I realize that github is the main priority for this project, however I'd like to know:

  • If support of other repository types is on the roadmap?
  • What would be the most reasonable way to configure this?

For example if one wanted to adjust #118 to support bitbucket or gitlab, they would need to make the repository icon customizable (instead of fa-github), and change the schema for pre-populating the issue title and description. This is all doable, but I'd like to know how would the user control it? Would there be a single "repository_type" configuration key?

Design: Move topbar icons into the right sidebar

Describe the change you'd like

The change would be to move topbar icons into the right sidebar, similar to how GitBook handles the "Edit on GitHub" button.

IMO, the right sidebar and left sidebar feel a little asymmetric in terms of the amount of content they hold. This would allow for balancing the amount of content on top of both the sidebars, while still providing the same functionality (with potentially text descriptions, if we decide to add them as an annotated list instead of as-is icons).

Describe alternatives you've considered

Maintain status quo. Or, add full-width top bar or something similar that's visually distinct from the rest of the content.

Additional context

I'm happy to try implementing this myself, if there's interest in this idea. :)

Content of "On this page" not shown in Safari

I use macOS 10.15.4 Catalina.
In this link, Safari 13.1 does NOT show the content of the On this page navigation menu at the top-right corner, whereas Firefox 75.0 and Chrome 81.0 do show it if the mouse cursor hovers over On this page.

[EDIT]
I also tried Safari on iPad Pro with iOS 13.4.1. The same problem as in Safari on Mac.

Awkward handling of mathjax in figure captions

I'm seeing some awkward clipping behavior on mathjax embeds in Figure captions. In Firefox, I see this:
image

which is generated by the following markdown:

```{glue:figure} shifting

*Left*: an impulse (top), a negative impulse (middle), and a 3-step delay (bottom).
*Middle*: the DFT spectrum (real and imaginary) components of each signal are distinct.
*Right*: all three signals have identical magnitude spectra $|X[m]| = 1$.
```

Note the truncated math span for $|X[m]| = 1$.

In Chromium, I see this:
image
which is at least not truncated, but the scaling seems incorrect to me.

(NB: I have some custom CSS to do justified text layout, but that's independent of this problem.)

The problem appears to come from a bad interaction between the book theme and mathjax due to setting font-size: 0.9em here

span {
font-size: .9em;
}

This appears to be fixed if I hack this in the console to scale up to font-size: 0.9rem (root scaling). It then renders as (in Firefox):
image

and in Chromium:
image

In both cases, the surrounding typesetting seems .... broken (note the unpredictable placement of the following punctuation). I'm not enough of a CSS wiz to sort that one out. EDIT: I think this one might be down to mathjax.


This problem may pop up in other places, and it's probably worth doing a thorough audit to ensure that root scalings are used where appropriate.

Figure out the right way to handle a sidebar

Right now, the sidebar pops up at a certain width and crowds the main content. I'm not sure whether this is ideal, we should figure out the right way to include sidebar content without wasting (or crowding) space.

Another option would be to have the sidebar overlap with the TOC, and figure out some way to prevent them from clashing in uncomfortable ways.

This is also related to having a "full-width" figure a-la Tufte, because some pages may have right sidebar white-space while others may not

An approach that mimics Jupyter Book:

  • Start off in-line
  • At a medium breakpoint:
    • sidebar items moves from inline to right-sidebar
    • width of content stays at 100%
    • The TOC also shows up, but it only shows on hover
  • At an xl breakpoint:
    • width of content moves down to ~70%
    • sidebar now takes up the extra 30% that's there
    • TOC content is shown all the time

"Strong" text is no different from regular text

Describe the bug
Text marked with <strong>...</strong> (obtained by **...** in Markdown in jupyter-book) looks just like regular text.

To Reproduce
Steps to reproduce the behavior:

  1. Surround some text in a jupyter-book project with double asterisks.
  2. Compile the project to a book.
  3. Visit the generated website in the browser.
  4. Notice that the marked text does not appear different from the surrounding text.
  5. Inspect the text using the browser's developer tools.
  6. Note that, while there are indeed <strong>...</strong> tags around the text.

Expected behavior
Strong text should appear emphasized, typically using bold.

The screenshot below was generated from the following Markdown:

## Functions

**Definition:** A *function* is any method for taking a list of inputs and determining the corresponding output.

Screen Shot 2020-06-12 at 9 45 31 AM

Environment (please complete the following information):

  • Python Version 3.7.3
  • Output of pip show jupyter-book says the version is 0.7.0b4.dev0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.