Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ uv export --format requirements-txt > requirements.txt
```bash
pip install -r requirements.txt
```
## Lucide icons

Use `|icon download|` in RST (see `conf.py`). Icon names can be found in `lucide_icons.py`,
generated from `_themes/theme/static/js/lucide.min.js`:

```bash
python scripts/generate_lucide_icons.py
```

Run again after replacing `lucide.min.js`.

## Build
English `en` is the default language.
Expand Down
5 changes: 5 additions & 0 deletions _themes/theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@

{# Keep modernizr in head - http://modernizr.com/docs/#installing #}
<script src="{{ pathto('_static/js/modernizr.min.js', 1) }}"></script>
{# Lucide icons #}
<script src="{{ pathto('_static/js/lucide.min.js', 1) }}"></script>

</head>

Expand Down Expand Up @@ -221,6 +223,9 @@
});
</script>

{# Lucide Icons #}
<script> lucide.createIcons() </script>

{%- block footer %} {% endblock %}

</body>
Expand Down
12 changes: 12 additions & 0 deletions _themes/theme/static/js/lucide.min.js

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os
from sphinx import addnodes
from docutils.nodes import strong, emphasis, reference, Text
from docutils.nodes import strong, emphasis, reference, Text, raw
from docutils.parsers.rst.roles import set_classes
from docutils.parsers.rst import Directive
import docutils.parsers.rst.directives as directives
Expand Down Expand Up @@ -173,8 +173,32 @@ def run(self):
prolog = '\n'.join(['.. |cptools %s| cptools:: %s' % (icon, icon) for icon in cptools_icons])
prolog += '\n'

# New 'raw' role for Lucide
prolog += '''.. role:: raw-html(raw)
:format: html\n'''

# Lucide icon directive
class Lucide(Directive):

has_content = True

def run(self):
icon_name = self.content[0]
node = raw(format="html", text=f"<i data-lucide='{icon_name}'></i>")
return [node]

# Import lucide icons file
from conf_icons import lucide_icons

prolog += '\n'.join(
['.. |icon %s| lucide:: %s' % (icon, icon) for icon in lucide_icons]
)
prolog += '\n'


def setup(app):
app.add_role('cptools', cptools_global())
app.add_directive('cptools', Cptools)
app.add_directive('lucide', Lucide)
app.config.rst_prolog += prolog
return {'version': '0.0.1'}
Loading