Skip to content

Commit

Permalink
Merge branch 'master' into rhs-toc-adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
AakashGfude authored Apr 28, 2023
2 parents 91f2ec9 + 558393d commit d00b16f
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 118 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ jobs:
- name: Fetch lecture-python-programming.myst
shell: bash -l {0}
run: |
git clone https://github.com/QuantEcon/lecture-python-programming.myst
cd lecture-python-programming.myst && git checkout rhs-toc-sticky && cd ..
git clone --branch quantecon-book-theme https://github.com/QuantEcon/lecture-python-programming.myst
- name: Setup Anaconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
auto-activate-base: true
miniconda-version: 'latest'
python-version: 3.8
python-version: 3.9
environment-file: lecture-python-programming.myst/environment.yml
activate-environment: lecture-python-programming
- name: Install quantecon-book-theme
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0
python-version: 3.9
- uses: pre-commit/action@v3.0.0

tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -39,7 +39,7 @@ jobs:
- name: Upload to Codecov
if: github.repository == 'QuantEcon/quantecon-book-theme'
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3.1.0
with:
name: ebp-sbt-pytests-py3.7
flags: pytests
Expand All @@ -53,11 +53,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.9
- name: Build package
run: |
pip install wheel
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ exclude: >
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.3.0
hooks:
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.8.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8

- repo: https://github.com/mgedmin/check-manifest
rev: "0.39"
hooks:
- id: check-manifest

- repo: https://github.com/executablebooks/web-compile
rev: v0.2.1
rev: v0.2.3
hooks:
- id: web-compile
files: >-
Expand Down
5 changes: 1 addition & 4 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Python API

.. autodata:: quantecon_book_theme.__version__

.. autoclass:: quantecon_book_theme.Margin
:members:
:undoc-members:
:show-inheritance:
.. autofunction:: quantecon_book_theme.add_to_context

.. autofunction:: quantecon_book_theme.launch.add_hub_urls
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

intersphinx_mapping = {
"python": ("https://docs.python.org/3.8", None),
"sphinx": ("https://www.sphinx-doc.org/en/3.x", None),
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
}
nitpick_ignore = [
("py:class", "docutils.nodes.document"),
Expand All @@ -57,7 +57,7 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
jupyter_execute_notebooks = "cache"
nb_execution_mode = "cache"
thebe_config = {
"repository_url": "https://github.com/binder-examples/jupyter-stacks-datascience",
"repository_branch": "master",
Expand All @@ -78,7 +78,6 @@
"use_issues_button": True,
"use_repository_button": True,
"expand_sections": ["reference/index"],
"logo_url": "https://quantecon.org"
# For testing
# "home_page_in_toc": True,
# "single_page": True
Expand Down
52 changes: 19 additions & 33 deletions docs/html/_sources/reference/markdown_limits.ipynb

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions docs/reference/markdown_limits.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@ fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", size="s
fig
```

and the same example with `jupyter-sphinx`.

```{jupyter-execute}
import plotly.io as pio
import plotly.express as px
import plotly.offline as py
pio.renderers.default = "notebook"
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", size="sepal_length")
fig
```

+++

## Hiding elements
Expand Down
23 changes: 14 additions & 9 deletions quantecon_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .launch import add_hub_urls

__version__ = "0.3.1"
__version__ = "0.4.2"
"""quantecon-book-theme version"""

SPHINX_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -68,7 +68,7 @@ def add_static_path(app):
def add_to_context(app, pagename, templatename, context, doctree):
"""Functions and variable additions to context."""

def sbt_generate_nav_html(
def sbt_generate_toctree_html(
level=1,
include_item_names=False,
with_home_page=False,
Expand All @@ -78,15 +78,15 @@ def sbt_generate_nav_html(
with_home_page = with_home_page.lower() == "true"

# Grab the raw toctree object and structure it so we can manipulate it
toc_sphinx = context["generate_nav_html"](
toctree = context["generate_toctree_html"](
startdepth=level - 1,
maxdepth=level + 1,
kind="sidebar",
collapse=False,
titles_only=True,
includehidden=True,
)
toctree = bs(toc_sphinx, "html.parser")
# toctree = bs(toc_sphinx, "html.parser")

# pair "current" with "active" since that's what we use w/ bootstrap
for li in toctree("li", {"class": "current"}):
Expand Down Expand Up @@ -180,15 +180,15 @@ def get_github_src_folder(app):
master_url = context["pathto"](master_doc)
context["master_url"] = master_url

# default value is book.tex
context["pdf_book_name"] = app.config.latex_documents[0][1].replace(".tex", "")
context["github_sourcefolder"] = get_github_src_folder(app)

context["sbt_generate_nav_html"] = sbt_generate_nav_html
context["sbt_generate_toctree_html"] = sbt_generate_toctree_html
context["generate_toc_html"] = generate_toc_html

# check if book pdf folder is present
if os.path.isdir(app.outdir + "/_pdf"):
if "pdf_book_name" not in context:
context["pdf_book_name"] = app.config.latex_documents[0][1].replace(
".tex", ""
)
context["pdf_book_path"] = "/_pdf/" + context["pdf_book_name"] + ".pdf"

# check if notebook folder is present
Expand Down Expand Up @@ -249,6 +249,11 @@ def get_github_src_folder(app):
# Disable using the button so we don't get errors
context["theme_use_edit_page_button"] = False

# default value is book.tex
if "pdf_book_name" not in context:
context["pdf_book_name"] = app.config.latex_documents[0][1].replace(".tex", "")
context["github_sourcefolder"] = get_github_src_folder(app)

# Make sure the context values are bool
btns = [
"theme_use_edit_page_button",
Expand Down
3 changes: 1 addition & 2 deletions quantecon_book_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
</div>

<nav class="qe-sidebar__nav" id="qe-sidebar-nav" aria-label="Main navigation">
{{ sbt_generate_nav_html(include_item_names=False, with_home_page=theme_home_page_in_toc) }}
{{ sbt_generate_toctree_html(include_item_names=False, with_home_page=theme_home_page_in_toc) }}
</nav>

<div class="qe-sidebar__footer">
Expand Down Expand Up @@ -363,7 +363,6 @@

</div> <!-- .wrapper-->
{%- block scripts_end %}
{{ generate_google_analytics_script(id=theme_google_analytics_id) }}
{%- endblock %}
{%- endblock %}

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion quantecon_book_theme/theme.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Note: this should only be changed in src/jinja/theme.conf.j2
[theme]
inherit = pydata_sphinx_theme
stylesheet = quantecon-book-theme.8e803950472302ed98c42444678c3bbd.css
stylesheet = quantecon-book-theme.27f831372ca8a27cbff86bbb33459986.css

[options]
single_page = False
Expand Down
19 changes: 9 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,40 @@
packages=find_packages(),
install_requires=[
"pyyaml",
"docutils>=0.15",
"sphinx>=4,<7",
"docutils",
"click",
"setuptools",
"libsass~=0.20.1",
"sphinx_book_theme~=0.1.0",
"sphinx_book_theme~=1.0.0",
"beautifulsoup4",
"web-compile",
"markupsafe~=2.0.1",
"sphinx<5,>=3",
'importlib-resources>=3.0,<3.5; python_version < "3.7"',
],
extras_require={
"code_style": ["flake8<3.8.0,>=3.7.0", "black", "pre-commit~=2.7.0"],
"code_style": ["flake8<3.8.0,>=3.7.0", "black", "pre-commit"],
"sphinx": [
"folium",
"numpy",
"matplotlib",
"ipywidgets",
"pandas",
"nbclient",
"myst-nb~=0.11.1",
"myst-nb~=0.17.1",
"sphinx-togglebutton>=0.2.1",
"sphinx-copybutton",
"plotly",
"sphinxcontrib-bibtex~=2.2",
"sphinxcontrib-bibtex>=2.2.0,<=2.5.0",
],
"testing": [
"myst-nb~=0.11.1",
"myst_nb~=0.17.1",
"coverage",
"pytest~=6.0.1",
"pytest~=7.1",
"pytest-cov",
"beautifulsoup4",
"sphinx_thebe",
"pytest-regressions~=2.0.1",
"sphinx_copybutton",
"sphinx_togglebutton",
],
},
entry_points={
Expand Down
26 changes: 18 additions & 8 deletions src/scss/quantecon-book-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@ tt {
/* tableofcontents directive caption option */
.caption-text {
font-weight: normal;
font-family: 'PT Serif', serif;
font-size: 1.2rem;
font-size: 1rem;
}

// Math equations
Expand Down Expand Up @@ -765,10 +764,6 @@ tt {
/* Custom content styles */
.qe-page__content {

.table-container {
overflow-x: scroll;
}

table {
max-width: 100%;
border-collapse: collapse;
Expand Down Expand Up @@ -974,7 +969,6 @@ tt {

.MathJax {
color: #333;
margin: 2rem 0;
}

a .MathJax {
Expand All @@ -990,6 +984,19 @@ tt {
&.align-right {
text-align: right;
}
p.caption {
span.caption-number {
font-style: normal;
font-weight: 700;
}
}
}

figcaption {
span.caption-number {
font-style: normal;
font-weight: 700;
}
}

div[class^='cell tag_collapse'] {
Expand Down Expand Up @@ -1042,7 +1049,10 @@ tt {
}

.cell_output {
img {
table {
table-layout: auto;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
Expand Down
2 changes: 1 addition & 1 deletion tests/sites/base/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
html_baseurl = "https://sphinx-book-theme.readthedocs.org"
html_copy_source = True
html_sourcelink_suffix = ""
jupyter_execute_notebooks = "auto"
nb_execution_mode = "auto"

# Base options, we can add other key/vals later
html_theme_options = {
Expand Down
5 changes: 2 additions & 3 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ def test_build_book(file_regression, sphinx_build):
for path, kernel in kernels_expected.items():
ntbk_text = sphinx_build.get(*path.split("/"))
thebe_config = ntbk_text.find("script", attrs={"type": "text/x-thebe-config"})
kernel_name = 'kernelName: "{}",'.format(kernel)
if kernel_name not in thebe_config.prettify():
raise AssertionError(f"{kernel_name} not in {kernels_expected}")
if kernel not in thebe_config.prettify():
raise AssertionError(f"{kernel} not in {kernels_expected}")

# Check a few components that should be true on each page
index_html = sphinx_build.get("index.html")
Expand Down
Loading

1 comment on commit d00b16f

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.