-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
463 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@use "bulma/sass/utilities/extends"; | ||
|
||
.sass-demo-bulma-content { | ||
@extend %control; | ||
background-color: purple; | ||
color: white; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
==================== | ||
atsphinx.toybox.sass | ||
==================== | ||
|
||
Overview | ||
======== | ||
|
||
This compiles SASS/SCSS resources into css when run sphinx-build. | ||
This it to embed Stlite content into your documents. | ||
|
||
Usage | ||
===== | ||
|
||
Enable extension | ||
---------------- | ||
|
||
Add this into your ``conf.py`` of Sphinx. | ||
|
||
.. code-block:: python | ||
:caption: conf.py | ||
extensions = [ | ||
"atsphinx.toybox.sass", | ||
] | ||
Configuration | ||
------------- | ||
|
||
There are not configuration options. | ||
|
||
.. note:: I will add some optioons. | ||
|
||
Demo | ||
==== | ||
|
||
This content is used generated CSS from SASS. | ||
|
||
.. code:: rst | ||
.. container:: sass-demo-bulma-content | ||
This paragraph is colored by "purplel". | ||
.. literalinclude:: ../../_sass/demo.scss | ||
:caption: docs/_sass/demo.scss | ||
|
||
Result: | ||
|
||
.. container:: sass-demo-bulma-content | ||
|
||
This paragraph is colored by "purplel". | ||
|
||
Refs | ||
==== | ||
|
||
* `dart-sacc CLI <https://sass-lang.com/documentation/cli/dart-sass/>`_ | ||
* `Repository <https://github.com/sass/dart-sass/>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "docs", | ||
"version": "2024.12.2", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"bulma": "^1.0.2" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Sass autobuild. | ||
Spec | ||
==== | ||
* Use dart-sass binary | ||
* Auto find ``_sass`` directory. | ||
* Exclude ``_`` prefixed files. | ||
* Copy into _static | ||
* Timestamp based incremental build. | ||
""" | ||
|
||
import subprocess | ||
from pathlib import Path | ||
|
||
from sphinx.application import Sphinx | ||
from sphinx.config import Config | ||
|
||
from . import dart_sass | ||
|
||
SASS_VERSION = "1.81.0" | ||
|
||
package_root = Path(__file__).parent | ||
|
||
bin_dist = package_root / "_bin" | ||
sass_bin: Path | ||
|
||
|
||
def configure_sass_bin(app: Sphinx, config: Config): | ||
"""Set up sass executable. It download binary if it needs.""" | ||
global sass_bin | ||
sass_bin = dart_sass.setup_dart_sass(SASS_VERSION, bin_dist) | ||
|
||
|
||
def compile_assets(app: Sphinx): | ||
"""Compile assets (sass or scss to css).""" | ||
global sass_bin | ||
source_dir = app.srcdir / "_sass" | ||
output_dir = app.srcdir / "_static" / "css" | ||
output_dir.mkdir(parents=True, exist_ok=True) | ||
options = [] | ||
if app.config.sass_load_paths: | ||
options += [f"--load-path={p}" for p in app.config.sass_load_paths] | ||
options += app.config.sass_extra_options | ||
cmd = [str(sass_bin), *options, f"{source_dir}:{output_dir}"] | ||
subprocess.run(cmd) | ||
|
||
|
||
def setup(app: Sphinx): # noqa: D103 | ||
app.add_config_value( | ||
"sass_load_paths", | ||
[], | ||
"env", | ||
list[str], | ||
"Path list of external import resources", | ||
) | ||
app.add_config_value( | ||
"sass_extra_options", | ||
[], | ||
"env", | ||
list[str], | ||
"Option arguments of dart-sass", | ||
) | ||
app.connect("config-inited", configure_sass_bin) | ||
app.connect("builder-inited", compile_assets) | ||
return {} |
Oops, something went wrong.