45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
#!/usr/bin/env python
|
|
# *****************************************************************************
|
|
# Copyright (C) 2023 Thomas Touhey <thomas@touhey.fr>
|
|
# This file is part of the textoutpc project, which is MIT-licensed.
|
|
# *****************************************************************************
|
|
"""Nodes specific to textoutpc.
|
|
|
|
The terminology used to categorize nodes defined here is from the `docutils
|
|
document tree <doctree_>`_ page, and as used in `nodes.py`_.
|
|
|
|
.. _doctree: https://docutils.sourceforge.io/docs/ref/doctree.html#toc-entry-1
|
|
.. _nodes.py:
|
|
https://github.com/docutils/docutils/blob/master/docutils/docutils/nodes.py
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from docutils.nodes import Body, Element, General, TextElement
|
|
|
|
|
|
class progress(General, TextElement):
|
|
"""Simple body element used to represent a progress bar, as a block."""
|
|
|
|
value: int
|
|
"""The value between 0 and 100 of the progress bar."""
|
|
|
|
def __init__(self, *args, value: int, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.value = value
|
|
|
|
|
|
class spoiler(Body, Element):
|
|
"""Compound body element used to represent a spoiler, as a block."""
|
|
|
|
closed_title: str
|
|
"""Label to display as the title while the spoiler is closed."""
|
|
|
|
opened_title: str
|
|
"""Label to display as the title while the spoiler is opened."""
|
|
|
|
def __init__(self, *args, closed_title: str, opened_title: str, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.closed_title = closed_title
|
|
self.opened_title = opened_title
|