Skip to content

Commit

Permalink
fix: remove important from highlight background (#2082)
Browse files Browse the repository at this point in the history
The `!important` modifier for the `div.highlight`
background messed up the specificity and didn't
work well with `myst_nb`. I should have updated this when we added
support for `pygments_style_dark`.
  • Loading branch information
kai687 authored Nov 26, 2024
1 parent cc1e4bf commit 8e9dced
Show file tree
Hide file tree
Showing 17 changed files with 1,328 additions and 288 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ docs/public/xml
.python-version
.env
.yarn
jupyter_execute
4 changes: 2 additions & 2 deletions docs/_static/feedback.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: flex;
gap: 0.5rem;
flex-direction: column;
padding-top: 1.5rem;
padding-block-start: 1.5rem;
align-items: center;
font-size: 0.875rem;
color: hsl(var(--muted-foreground));
Expand All @@ -23,7 +23,7 @@
}

#upvote > svg {
margin-bottom: 5px;
margin-block-end: 5px;
}

#downvote:hover,
Expand Down
7 changes: 6 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
"sphinx_sitemap",
"sphinx_design",
"sphinx_docsearch",
"myst_nb",
]

exclude_patterns = ["public", "includes", "**/includes"]
exclude_patterns = ["public", "includes", "**/includes", "jupyter_execute"]

nitpicky = True

Expand Down Expand Up @@ -96,6 +97,10 @@
templates_path = ["_templates"]
# html_additional_pages = {"about": "about.html"}

# Separate syntax highlighting styles for light and dark mode
# pygments_style = "xcode"
# pygments_style_dark = "github-dark"

html_static_path = ["_static"]
html_css_files = ["feedback.css"]
html_js_files = [("feedback.js", {"defer": "defer"})]
Expand Down
15 changes: 15 additions & 0 deletions docs/demo/myst-nb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
file_format: mystnb
kernelspec:
name: python3
---

# Jupyter notebooks

This theme should look ok with the `myst-nb` extension.

```{code-cell} ipython3
a = "This is "
b = "Python"
print(f"{a}{b}")
```
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "sphinxawesome-theme"
version = "6.0.0a1"
version = "6.0.0a2"
description = "An awesome theme for the Sphinx documentation generator"
readme = "README.md"
authors = [
Expand Down Expand Up @@ -45,6 +45,7 @@ build-backend = "hatchling.build"

[dependency-groups]
docs = [
"myst-nb",
"python-dotenv",
"sphinx-autoapi",
"sphinx-autobuild",
Expand Down
73 changes: 60 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,116 @@
-e .
alabaster==0.7.16
anyio==4.6.2.post1
appnope==0.1.4 ; platform_system == 'Darwin'
argcomplete==3.5.1
astroid==3.3.5
asttokens==2.4.1
attrs==24.2.0
babel==2.16.0
beautifulsoup4==4.9.3
beautifulsoup4==4.12.3
certifi==2024.8.30
cffi==1.17.1 ; implementation_name == 'pypy'
charset-normalizer==3.4.0
click==8.1.7
colorama==0.4.6
colorlog==6.9.0
coverage==7.6.7
comm==0.2.2
coverage==7.6.8
debugpy==1.8.9
decorator==5.1.1
distlib==0.3.9
docutils==0.21.2
exceptiongroup==1.2.2 ; python_full_version < '3.11'
executing==2.1.0
fastjsonschema==2.20.0
filelock==3.16.1
greenlet==3.1.1 ; (python_full_version < '3.13' and platform_machine == 'AMD64') or (python_full_version < '3.13' and platform_machine == 'WIN32') or (python_full_version < '3.13' and platform_machine == 'aarch64') or (python_full_version < '3.13' and platform_machine == 'amd64') or (python_full_version < '3.13' and platform_machine == 'ppc64le') or (python_full_version < '3.13' and platform_machine == 'win32') or (python_full_version < '3.13' and platform_machine == 'x86_64')
h11==0.14.0
idna==3.10
imagesize==1.4.1
importlib-metadata==8.5.0 ; python_full_version < '3.10'
importlib-metadata==8.5.0
iniconfig==2.0.0
ipykernel==6.29.5
ipython==8.18.1
jedi==0.19.2
jinja2==3.1.4
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter-cache==1.0.1
jupyter-client==8.6.3
jupyter-core==5.7.2
markdown-it-py==3.0.0
markupsafe==3.0.2
matplotlib-inline==0.1.7
mdit-py-plugins==0.4.2
mdurl==0.1.2
myst-nb==1.1.2
myst-parser==3.0.1
nbclient==0.10.0
nbformat==5.10.4
nest-asyncio==1.6.0
nodeenv==1.9.1
nox==2024.10.9
packaging==24.2
parso==0.8.4
pexpect==4.9.0 ; sys_platform != 'win32'
platformdirs==4.3.6
pluggy==1.5.0
prompt-toolkit==3.0.48
psutil==6.1.0
ptyprocess==0.7.0 ; sys_platform != 'win32'
pure-eval==0.2.3
pycparser==2.22 ; implementation_name == 'pypy'
pygments==2.18.0
pyright==1.1.389
pytest==8.3.3
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pywin32==308 ; platform_python_implementation != 'PyPy' and sys_platform == 'win32'
pyyaml==6.0.2
pyzmq==26.2.0
referencing==0.35.1
requests==2.32.3
ruff==0.7.4
rpds-py==0.21.0
ruff==0.8.0
six==1.16.0
sniffio==1.3.1
snowballstemmer==2.2.0
soupsieve==2.6
sphinx==7.3.7 ; python_full_version >= '3.10'
sphinx==7.4.7 ; python_full_version < '3.10'
sphinx==8.1.3 ; python_full_version >= '3.10'
sphinx-autoapi==3.3.3
sphinx-autobuild==2024.10.3
sphinx-design==0.6.1
sphinx-docsearch==0.1.0
sphinx-docsearch==0.0.8 ; python_full_version >= '3.10'
sphinx-docsearch==0.1.0 ; python_full_version < '3.10'
sphinx-sitemap==2.6.0
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
starlette==0.41.2
sqlalchemy==2.0.36
stack-data==0.6.3
starlette==0.41.3
stdlib-list==0.11.0 ; python_full_version < '3.10'
tabulate==0.9.0
tomli==2.1.0 ; python_full_version <= '3.11'
tornado==6.4.2
traitlets==5.14.3
types-beautifulsoup4==4.12.0.20241020
types-docutils==0.21.0.20241005
types-html5lib==1.1.11.20241018
types-pygments==2.18.0.20240506
types-setuptools==75.4.0.20241115
types-setuptools==75.6.0.20241126
typing-extensions==4.12.2
urllib3==2.2.3
uv==0.5.3
uvicorn==0.32.0
virtualenv==20.27.1
watchfiles==0.24.0
uv==0.5.4
uvicorn==0.32.1
virtualenv==20.28.0
watchfiles==1.0.0
wcwidth==0.2.13
websockets==14.1
zipp==3.21.0 ; python_full_version < '3.10'
zipp==3.21.0
3 changes: 3 additions & 0 deletions src/sphinxawesome_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def setup(app: Sphinx) -> dict[str, Any]:
# Add the CSS overrides if we're using the `sphinx-design` extension
if "sphinx_design" in app.config.extensions:
app.add_css_file("awesome-sphinx-design.css", priority=900)
# Add the CSS overrides if we're using the `myst-nb` extension
if "myst_nb" in app.config.extensions:
app.add_css_file("awesome-myst-nb.css", priority=900)

if "sphinx_docsearch" in app.config.extensions:
app.add_css_file("awesome-docsearch.css", priority=900)
Expand Down
1 change: 1 addition & 0 deletions src/sphinxawesome_theme/static/awesome-myst-nb.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/sphinxawesome_theme/static/theme.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/theme-src/css/code.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Code-related styles */

.highlight {
@apply relative !bg-transparent;
@apply relative bg-transparent;

&:hover .copy {
@apply opacity-100;
Expand Down
8 changes: 8 additions & 0 deletions src/theme-src/css/myst-nb.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* Overrides for the `myst-nb` extension */
:root {
--mystnb-stdout-bg-color: theme(colors.background);
--mystnb-stdout-border-color: theme(colors.border);
--mystnb-source-bg-color: theme(colors.background);
--mystnb-source-border-color: theme(colors.border);
--mystnb-source-border-radius: theme(borderRadius.lg);
}
4 changes: 2 additions & 2 deletions src/theme-src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sphinxawesome-theme",
"version": "6.0.0a1",
"version": "6.0.0a2",
"scripts": {
"build": "webpack",
"format": "prettier --write */**/*.{css,js} */*.{css,js} *.js"
Expand Down Expand Up @@ -35,7 +35,7 @@
"postcss-import": "^16.1.0",
"postcss-loader": "^8.1.1",
"postcss-preset-env": "^10.1.1",
"prettier": "^3.3.3",
"prettier": "^3.4.0",
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-tailwindcss": "^0.6.9",
"stylelint": "^16.10.0",
Expand Down
Loading

0 comments on commit 8e9dced

Please sign in to comment.