From 5194582ff5786905489e1cd8c08b201efdb931be Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Mon, 25 Mar 2024 01:20:59 +0000 Subject: [PATCH 1/3] Add exports to table.columns --- src/bootlace/table/columns.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootlace/table/columns.py b/src/bootlace/table/columns.py index 543230c..0d883ce 100644 --- a/src/bootlace/table/columns.py +++ b/src/bootlace/table/columns.py @@ -10,6 +10,9 @@ from bootlace.util import as_tag +__all__ = ["Column", "EditColumn", "CheckColumn", "Datetime"] + + @attrs.define class Column(ColumnBase): From a68cf6d5d665f3cf715bd605fa6d190013b860ed Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Mon, 25 Mar 2024 17:12:03 +0000 Subject: [PATCH 2/3] Initial work on documentation for bootlace --- docs/Makefile | 4 +- .../bootlace.forms.fields.BooleanField.rst | 31 ++++++++++ docs/api/bootlace.forms.fields.ColorField.rst | 17 ++++++ docs/api/bootlace.forms.fields.DateField.rst | 27 +++++++++ .../bootlace.forms.fields.DateTimeField.rst | 27 +++++++++ ...otlace.forms.fields.DateTimeLocalField.rst | 17 ++++++ .../bootlace.forms.fields.DecimalField.rst | 27 +++++++++ ...ootlace.forms.fields.DecimalRangeField.rst | 17 ++++++ docs/api/bootlace.forms.fields.EmailField.rst | 17 ++++++ docs/api/bootlace.forms.fields.EnumField.rst | 7 +++ docs/api/bootlace.forms.fields.Field.rst | 57 +++++++++++++++++++ docs/api/bootlace.forms.fields.FieldList.rst | 37 ++++++++++++ docs/api/bootlace.forms.fields.FileField.rst | 17 ++++++ docs/api/bootlace.forms.fields.Flags.rst | 7 +++ docs/api/bootlace.forms.fields.FloatField.rst | 27 +++++++++ docs/api/bootlace.forms.fields.FormField.rst | 35 ++++++++++++ .../api/bootlace.forms.fields.HiddenField.rst | 17 ++++++ .../bootlace.forms.fields.IntegerField.rst | 29 ++++++++++ ...ootlace.forms.fields.IntegerRangeField.rst | 17 ++++++ .../bootlace.forms.fields.KnownMIMEType.rst | 17 ++++++ docs/api/bootlace.forms.fields.Label.rst | 17 ++++++ .../bootlace.forms.fields.MarkdownField.rst | 7 +++ docs/api/bootlace.forms.fields.MonthField.rst | 17 ++++++ ...ootlace.forms.fields.MultipleFileField.rst | 27 +++++++++ .../bootlace.forms.fields.PasswordField.rst | 17 ++++++ docs/api/bootlace.forms.fields.RadioField.rst | 19 +++++++ .../api/bootlace.forms.fields.SearchField.rst | 17 ++++++ .../api/bootlace.forms.fields.SelectField.rst | 37 ++++++++++++ .../bootlace.forms.fields.SelectFieldBase.rst | 31 ++++++++++ ...tlace.forms.fields.SelectMultipleField.rst | 31 ++++++++++ .../api/bootlace.forms.fields.StringField.rst | 27 +++++++++ .../api/bootlace.forms.fields.SubmitField.rst | 17 ++++++ docs/api/bootlace.forms.fields.TelField.rst | 17 ++++++ .../bootlace.forms.fields.TextAreaField.rst | 17 ++++++ docs/api/bootlace.forms.fields.TimeField.rst | 27 +++++++++ docs/api/bootlace.forms.fields.URLField.rst | 17 ++++++ docs/api/bootlace.forms.fields.WeekField.rst | 27 +++++++++ docs/api/bootlace.forms.widgets.Switch.rst | 17 ++++++ docs/api/bootlace.icon.Icon.rst | 27 +++++++++ docs/conf.py | 2 + docs/index.rst | 1 + docs/reference.rst | 8 +++ docs/reference/breadcrumbs.rst | 30 ++++++++++ docs/reference/forms.rst | 7 +++ docs/reference/icon.rst | 4 ++ requirements/dev.in | 1 + requirements/dev.txt | 45 ++++++--------- requirements/tests.txt | 2 +- src/bootlace/breadcrumbs.py | 42 +++++++++++++- src/bootlace/forms/fields.py | 18 ++++++ src/bootlace/forms/widgets.py | 2 + src/bootlace/icon.py | 17 +++++- 52 files changed, 1007 insertions(+), 36 deletions(-) create mode 100644 docs/api/bootlace.forms.fields.BooleanField.rst create mode 100644 docs/api/bootlace.forms.fields.ColorField.rst create mode 100644 docs/api/bootlace.forms.fields.DateField.rst create mode 100644 docs/api/bootlace.forms.fields.DateTimeField.rst create mode 100644 docs/api/bootlace.forms.fields.DateTimeLocalField.rst create mode 100644 docs/api/bootlace.forms.fields.DecimalField.rst create mode 100644 docs/api/bootlace.forms.fields.DecimalRangeField.rst create mode 100644 docs/api/bootlace.forms.fields.EmailField.rst create mode 100644 docs/api/bootlace.forms.fields.EnumField.rst create mode 100644 docs/api/bootlace.forms.fields.Field.rst create mode 100644 docs/api/bootlace.forms.fields.FieldList.rst create mode 100644 docs/api/bootlace.forms.fields.FileField.rst create mode 100644 docs/api/bootlace.forms.fields.Flags.rst create mode 100644 docs/api/bootlace.forms.fields.FloatField.rst create mode 100644 docs/api/bootlace.forms.fields.FormField.rst create mode 100644 docs/api/bootlace.forms.fields.HiddenField.rst create mode 100644 docs/api/bootlace.forms.fields.IntegerField.rst create mode 100644 docs/api/bootlace.forms.fields.IntegerRangeField.rst create mode 100644 docs/api/bootlace.forms.fields.KnownMIMEType.rst create mode 100644 docs/api/bootlace.forms.fields.Label.rst create mode 100644 docs/api/bootlace.forms.fields.MarkdownField.rst create mode 100644 docs/api/bootlace.forms.fields.MonthField.rst create mode 100644 docs/api/bootlace.forms.fields.MultipleFileField.rst create mode 100644 docs/api/bootlace.forms.fields.PasswordField.rst create mode 100644 docs/api/bootlace.forms.fields.RadioField.rst create mode 100644 docs/api/bootlace.forms.fields.SearchField.rst create mode 100644 docs/api/bootlace.forms.fields.SelectField.rst create mode 100644 docs/api/bootlace.forms.fields.SelectFieldBase.rst create mode 100644 docs/api/bootlace.forms.fields.SelectMultipleField.rst create mode 100644 docs/api/bootlace.forms.fields.StringField.rst create mode 100644 docs/api/bootlace.forms.fields.SubmitField.rst create mode 100644 docs/api/bootlace.forms.fields.TelField.rst create mode 100644 docs/api/bootlace.forms.fields.TextAreaField.rst create mode 100644 docs/api/bootlace.forms.fields.TimeField.rst create mode 100644 docs/api/bootlace.forms.fields.URLField.rst create mode 100644 docs/api/bootlace.forms.fields.WeekField.rst create mode 100644 docs/api/bootlace.forms.widgets.Switch.rst create mode 100644 docs/api/bootlace.icon.Icon.rst create mode 100644 docs/reference.rst create mode 100644 docs/reference/breadcrumbs.rst create mode 100644 docs/reference/forms.rst create mode 100644 docs/reference/icon.rst diff --git a/docs/Makefile b/docs/Makefile index af0d16c..ed88099 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = . +SOURCEDIR = . +BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: diff --git a/docs/api/bootlace.forms.fields.BooleanField.rst b/docs/api/bootlace.forms.fields.BooleanField.rst new file mode 100644 index 0000000..8439561 --- /dev/null +++ b/docs/api/bootlace.forms.fields.BooleanField.rst @@ -0,0 +1,31 @@ +BooleanField +============ + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: BooleanField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~BooleanField.false_values + ~BooleanField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~BooleanField.process_data + ~BooleanField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: false_values + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_data + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.ColorField.rst b/docs/api/bootlace.forms.fields.ColorField.rst new file mode 100644 index 0000000..c97c73c --- /dev/null +++ b/docs/api/bootlace.forms.fields.ColorField.rst @@ -0,0 +1,17 @@ +ColorField +========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: ColorField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~ColorField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.DateField.rst b/docs/api/bootlace.forms.fields.DateField.rst new file mode 100644 index 0000000..1efcfbb --- /dev/null +++ b/docs/api/bootlace.forms.fields.DateField.rst @@ -0,0 +1,27 @@ +DateField +========= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: DateField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~DateField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~DateField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.DateTimeField.rst b/docs/api/bootlace.forms.fields.DateTimeField.rst new file mode 100644 index 0000000..bc26e5f --- /dev/null +++ b/docs/api/bootlace.forms.fields.DateTimeField.rst @@ -0,0 +1,27 @@ +DateTimeField +============= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: DateTimeField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~DateTimeField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~DateTimeField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.DateTimeLocalField.rst b/docs/api/bootlace.forms.fields.DateTimeLocalField.rst new file mode 100644 index 0000000..c4cec67 --- /dev/null +++ b/docs/api/bootlace.forms.fields.DateTimeLocalField.rst @@ -0,0 +1,17 @@ +DateTimeLocalField +================== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: DateTimeLocalField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~DateTimeLocalField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.DecimalField.rst b/docs/api/bootlace.forms.fields.DecimalField.rst new file mode 100644 index 0000000..d70b214 --- /dev/null +++ b/docs/api/bootlace.forms.fields.DecimalField.rst @@ -0,0 +1,27 @@ +DecimalField +============ + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: DecimalField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~DecimalField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~DecimalField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.DecimalRangeField.rst b/docs/api/bootlace.forms.fields.DecimalRangeField.rst new file mode 100644 index 0000000..4c02bb0 --- /dev/null +++ b/docs/api/bootlace.forms.fields.DecimalRangeField.rst @@ -0,0 +1,17 @@ +DecimalRangeField +================= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: DecimalRangeField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~DecimalRangeField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.EmailField.rst b/docs/api/bootlace.forms.fields.EmailField.rst new file mode 100644 index 0000000..8d26f65 --- /dev/null +++ b/docs/api/bootlace.forms.fields.EmailField.rst @@ -0,0 +1,17 @@ +EmailField +========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: EmailField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~EmailField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.EnumField.rst b/docs/api/bootlace.forms.fields.EnumField.rst new file mode 100644 index 0000000..cea7404 --- /dev/null +++ b/docs/api/bootlace.forms.fields.EnumField.rst @@ -0,0 +1,7 @@ +EnumField +========= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: EnumField + :show-inheritance: diff --git a/docs/api/bootlace.forms.fields.Field.rst b/docs/api/bootlace.forms.fields.Field.rst new file mode 100644 index 0000000..e2c75ca --- /dev/null +++ b/docs/api/bootlace.forms.fields.Field.rst @@ -0,0 +1,57 @@ +Field +===== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: Field + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Field.do_not_call_in_templates + ~Field.errors + ~Field.process_errors + ~Field.raw_data + ~Field.validators + ~Field.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Field.__call__ + ~Field.check_validators + ~Field.gettext + ~Field.ngettext + ~Field.populate_obj + ~Field.post_validate + ~Field.pre_validate + ~Field.process + ~Field.process_data + ~Field.process_formdata + ~Field.validate + + .. rubric:: Attributes Documentation + + .. autoattribute:: do_not_call_in_templates + .. autoattribute:: errors + .. autoattribute:: process_errors + .. autoattribute:: raw_data + .. autoattribute:: validators + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: check_validators + .. automethod:: gettext + .. automethod:: ngettext + .. automethod:: populate_obj + .. automethod:: post_validate + .. automethod:: pre_validate + .. automethod:: process + .. automethod:: process_data + .. automethod:: process_formdata + .. automethod:: validate diff --git a/docs/api/bootlace.forms.fields.FieldList.rst b/docs/api/bootlace.forms.fields.FieldList.rst new file mode 100644 index 0000000..b62fa7a --- /dev/null +++ b/docs/api/bootlace.forms.fields.FieldList.rst @@ -0,0 +1,37 @@ +FieldList +========= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: FieldList + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~FieldList.data + ~FieldList.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~FieldList.append_entry + ~FieldList.pop_entry + ~FieldList.populate_obj + ~FieldList.process + ~FieldList.validate + + .. rubric:: Attributes Documentation + + .. autoattribute:: data + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: append_entry + .. automethod:: pop_entry + .. automethod:: populate_obj + .. automethod:: process + .. automethod:: validate diff --git a/docs/api/bootlace.forms.fields.FileField.rst b/docs/api/bootlace.forms.fields.FileField.rst new file mode 100644 index 0000000..28479eb --- /dev/null +++ b/docs/api/bootlace.forms.fields.FileField.rst @@ -0,0 +1,17 @@ +FileField +========= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: FileField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~FileField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.Flags.rst b/docs/api/bootlace.forms.fields.Flags.rst new file mode 100644 index 0000000..5348fb0 --- /dev/null +++ b/docs/api/bootlace.forms.fields.Flags.rst @@ -0,0 +1,7 @@ +Flags +===== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: Flags + :show-inheritance: diff --git a/docs/api/bootlace.forms.fields.FloatField.rst b/docs/api/bootlace.forms.fields.FloatField.rst new file mode 100644 index 0000000..e58484b --- /dev/null +++ b/docs/api/bootlace.forms.fields.FloatField.rst @@ -0,0 +1,27 @@ +FloatField +========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: FloatField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~FloatField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~FloatField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.FormField.rst b/docs/api/bootlace.forms.fields.FormField.rst new file mode 100644 index 0000000..047a518 --- /dev/null +++ b/docs/api/bootlace.forms.fields.FormField.rst @@ -0,0 +1,35 @@ +FormField +========= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: FormField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~FormField.data + ~FormField.errors + ~FormField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~FormField.populate_obj + ~FormField.process + ~FormField.validate + + .. rubric:: Attributes Documentation + + .. autoattribute:: data + .. autoattribute:: errors + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: populate_obj + .. automethod:: process + .. automethod:: validate diff --git a/docs/api/bootlace.forms.fields.HiddenField.rst b/docs/api/bootlace.forms.fields.HiddenField.rst new file mode 100644 index 0000000..58ded87 --- /dev/null +++ b/docs/api/bootlace.forms.fields.HiddenField.rst @@ -0,0 +1,17 @@ +HiddenField +=========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: HiddenField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~HiddenField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.IntegerField.rst b/docs/api/bootlace.forms.fields.IntegerField.rst new file mode 100644 index 0000000..7e5e1ca --- /dev/null +++ b/docs/api/bootlace.forms.fields.IntegerField.rst @@ -0,0 +1,29 @@ +IntegerField +============ + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: IntegerField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~IntegerField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~IntegerField.process_data + ~IntegerField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_data + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.IntegerRangeField.rst b/docs/api/bootlace.forms.fields.IntegerRangeField.rst new file mode 100644 index 0000000..8277763 --- /dev/null +++ b/docs/api/bootlace.forms.fields.IntegerRangeField.rst @@ -0,0 +1,17 @@ +IntegerRangeField +================= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: IntegerRangeField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~IntegerRangeField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.KnownMIMEType.rst b/docs/api/bootlace.forms.fields.KnownMIMEType.rst new file mode 100644 index 0000000..c207bab --- /dev/null +++ b/docs/api/bootlace.forms.fields.KnownMIMEType.rst @@ -0,0 +1,17 @@ +KnownMIMEType +============= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: KnownMIMEType + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~KnownMIMEType.__call__ + + .. rubric:: Methods Documentation + + .. automethod:: __call__ diff --git a/docs/api/bootlace.forms.fields.Label.rst b/docs/api/bootlace.forms.fields.Label.rst new file mode 100644 index 0000000..0772bb3 --- /dev/null +++ b/docs/api/bootlace.forms.fields.Label.rst @@ -0,0 +1,17 @@ +Label +===== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: Label + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Label.__call__ + + .. rubric:: Methods Documentation + + .. automethod:: __call__ diff --git a/docs/api/bootlace.forms.fields.MarkdownField.rst b/docs/api/bootlace.forms.fields.MarkdownField.rst new file mode 100644 index 0000000..bb78918 --- /dev/null +++ b/docs/api/bootlace.forms.fields.MarkdownField.rst @@ -0,0 +1,7 @@ +MarkdownField +============= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: MarkdownField + :show-inheritance: diff --git a/docs/api/bootlace.forms.fields.MonthField.rst b/docs/api/bootlace.forms.fields.MonthField.rst new file mode 100644 index 0000000..0586ef6 --- /dev/null +++ b/docs/api/bootlace.forms.fields.MonthField.rst @@ -0,0 +1,17 @@ +MonthField +========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: MonthField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~MonthField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.MultipleFileField.rst b/docs/api/bootlace.forms.fields.MultipleFileField.rst new file mode 100644 index 0000000..45dca24 --- /dev/null +++ b/docs/api/bootlace.forms.fields.MultipleFileField.rst @@ -0,0 +1,27 @@ +MultipleFileField +================= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: MultipleFileField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~MultipleFileField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~MultipleFileField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.PasswordField.rst b/docs/api/bootlace.forms.fields.PasswordField.rst new file mode 100644 index 0000000..d8a7b0e --- /dev/null +++ b/docs/api/bootlace.forms.fields.PasswordField.rst @@ -0,0 +1,17 @@ +PasswordField +============= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: PasswordField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~PasswordField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.RadioField.rst b/docs/api/bootlace.forms.fields.RadioField.rst new file mode 100644 index 0000000..0e84381 --- /dev/null +++ b/docs/api/bootlace.forms.fields.RadioField.rst @@ -0,0 +1,19 @@ +RadioField +========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: RadioField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~RadioField.option_widget + ~RadioField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: option_widget + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.SearchField.rst b/docs/api/bootlace.forms.fields.SearchField.rst new file mode 100644 index 0000000..96d740e --- /dev/null +++ b/docs/api/bootlace.forms.fields.SearchField.rst @@ -0,0 +1,17 @@ +SearchField +=========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: SearchField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~SearchField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.SelectField.rst b/docs/api/bootlace.forms.fields.SelectField.rst new file mode 100644 index 0000000..293f98e --- /dev/null +++ b/docs/api/bootlace.forms.fields.SelectField.rst @@ -0,0 +1,37 @@ +SelectField +=========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: SelectField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~SelectField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~SelectField.has_groups + ~SelectField.iter_choices + ~SelectField.iter_groups + ~SelectField.pre_validate + ~SelectField.process_data + ~SelectField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: has_groups + .. automethod:: iter_choices + .. automethod:: iter_groups + .. automethod:: pre_validate + .. automethod:: process_data + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.SelectFieldBase.rst b/docs/api/bootlace.forms.fields.SelectFieldBase.rst new file mode 100644 index 0000000..23ef259 --- /dev/null +++ b/docs/api/bootlace.forms.fields.SelectFieldBase.rst @@ -0,0 +1,31 @@ +SelectFieldBase +=============== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: SelectFieldBase + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~SelectFieldBase.option_widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~SelectFieldBase.has_groups + ~SelectFieldBase.iter_choices + ~SelectFieldBase.iter_groups + + .. rubric:: Attributes Documentation + + .. autoattribute:: option_widget + + .. rubric:: Methods Documentation + + .. automethod:: has_groups + .. automethod:: iter_choices + .. automethod:: iter_groups diff --git a/docs/api/bootlace.forms.fields.SelectMultipleField.rst b/docs/api/bootlace.forms.fields.SelectMultipleField.rst new file mode 100644 index 0000000..4e9c074 --- /dev/null +++ b/docs/api/bootlace.forms.fields.SelectMultipleField.rst @@ -0,0 +1,31 @@ +SelectMultipleField +=================== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: SelectMultipleField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~SelectMultipleField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~SelectMultipleField.pre_validate + ~SelectMultipleField.process_data + ~SelectMultipleField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: pre_validate + .. automethod:: process_data + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.StringField.rst b/docs/api/bootlace.forms.fields.StringField.rst new file mode 100644 index 0000000..f33ac46 --- /dev/null +++ b/docs/api/bootlace.forms.fields.StringField.rst @@ -0,0 +1,27 @@ +StringField +=========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: StringField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~StringField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~StringField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.SubmitField.rst b/docs/api/bootlace.forms.fields.SubmitField.rst new file mode 100644 index 0000000..70a95e9 --- /dev/null +++ b/docs/api/bootlace.forms.fields.SubmitField.rst @@ -0,0 +1,17 @@ +SubmitField +=========== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: SubmitField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~SubmitField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.TelField.rst b/docs/api/bootlace.forms.fields.TelField.rst new file mode 100644 index 0000000..27c839a --- /dev/null +++ b/docs/api/bootlace.forms.fields.TelField.rst @@ -0,0 +1,17 @@ +TelField +======== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: TelField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~TelField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.TextAreaField.rst b/docs/api/bootlace.forms.fields.TextAreaField.rst new file mode 100644 index 0000000..a69103d --- /dev/null +++ b/docs/api/bootlace.forms.fields.TextAreaField.rst @@ -0,0 +1,17 @@ +TextAreaField +============= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: TextAreaField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~TextAreaField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.TimeField.rst b/docs/api/bootlace.forms.fields.TimeField.rst new file mode 100644 index 0000000..f7d522f --- /dev/null +++ b/docs/api/bootlace.forms.fields.TimeField.rst @@ -0,0 +1,27 @@ +TimeField +========= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: TimeField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~TimeField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~TimeField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.fields.URLField.rst b/docs/api/bootlace.forms.fields.URLField.rst new file mode 100644 index 0000000..d445a68 --- /dev/null +++ b/docs/api/bootlace.forms.fields.URLField.rst @@ -0,0 +1,17 @@ +URLField +======== + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: URLField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~URLField.widget + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget diff --git a/docs/api/bootlace.forms.fields.WeekField.rst b/docs/api/bootlace.forms.fields.WeekField.rst new file mode 100644 index 0000000..f21acda --- /dev/null +++ b/docs/api/bootlace.forms.fields.WeekField.rst @@ -0,0 +1,27 @@ +WeekField +========= + +.. currentmodule:: bootlace.forms.fields + +.. autoclass:: WeekField + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~WeekField.widget + + .. rubric:: Methods Summary + + .. autosummary:: + + ~WeekField.process_formdata + + .. rubric:: Attributes Documentation + + .. autoattribute:: widget + + .. rubric:: Methods Documentation + + .. automethod:: process_formdata diff --git a/docs/api/bootlace.forms.widgets.Switch.rst b/docs/api/bootlace.forms.widgets.Switch.rst new file mode 100644 index 0000000..caadabb --- /dev/null +++ b/docs/api/bootlace.forms.widgets.Switch.rst @@ -0,0 +1,17 @@ +Switch +====== + +.. currentmodule:: bootlace.forms.widgets + +.. autoclass:: Switch + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Switch.__call__ + + .. rubric:: Methods Documentation + + .. automethod:: __call__ diff --git a/docs/api/bootlace.icon.Icon.rst b/docs/api/bootlace.icon.Icon.rst new file mode 100644 index 0000000..c5e3bcf --- /dev/null +++ b/docs/api/bootlace.icon.Icon.rst @@ -0,0 +1,27 @@ +Icon +==== + +.. currentmodule:: bootlace.icon + +.. autoclass:: Icon + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Icon.endpoint + ~Icon.filename + ~Icon.height + ~Icon.name + ~Icon.url + ~Icon.width + + .. rubric:: Attributes Documentation + + .. autoattribute:: endpoint + .. autoattribute:: filename + .. autoattribute:: height + .. autoattribute:: name + .. autoattribute:: url + .. autoattribute:: width diff --git a/docs/conf.py b/docs/conf.py index 5e04bfd..47bdfbd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,9 @@ extensions: list[str] = [ "sphinx_automodapi.automodapi", + "sphinx_automodapi.smart_resolver", "sphinx.ext.autodoc", + "sphinx.ext.autosummary", "sphinx.ext.viewcode", "sphinx_mdinclude", ] diff --git a/docs/index.rst b/docs/index.rst index 13623f3..3637cd7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,6 +10,7 @@ Welcome to Bootlace's documentation! :maxdepth: 2 :caption: Contents: + reference Indices and tables diff --git a/docs/reference.rst b/docs/reference.rst new file mode 100644 index 0000000..139a1b9 --- /dev/null +++ b/docs/reference.rst @@ -0,0 +1,8 @@ +API Reference +============= + +.. toctree:: + + reference/breadcrumbs + reference/forms + reference/icon diff --git a/docs/reference/breadcrumbs.rst b/docs/reference/breadcrumbs.rst new file mode 100644 index 0000000..ea29d2e --- /dev/null +++ b/docs/reference/breadcrumbs.rst @@ -0,0 +1,30 @@ +.. currentmodule:: bootlace.breadcrumbs + +Breadcrumbs +=========== + +Breadcrumbs provide navigation helpers showing the heirarchy for the current page. Bootstrap +provides a default style for breadcrumbs: https://getbootstrap.com/docs/5.3/components/breadcrumb/ + +.. autosummary:: + + Breadcrumbs + Breadcrumb + BreadcrumbExtension + + +.. autoclass:: Breadcrumbs + :members: + +.. autoclass:: Breadcrumb + :members: + +.. autoclass:: BreadcrumbExtension + :members: + + +Additional Data Objects +----------------------- + +.. autoclass:: Endpoint + :members: diff --git a/docs/reference/forms.rst b/docs/reference/forms.rst new file mode 100644 index 0000000..18cf60b --- /dev/null +++ b/docs/reference/forms.rst @@ -0,0 +1,7 @@ +Forms +===== + +.. automodapi:: bootlace.forms.fields + :allowed-package-names: bootlace.form.fields,wtforms.fields + +.. automodapi:: bootlace.forms.widgets diff --git a/docs/reference/icon.rst b/docs/reference/icon.rst new file mode 100644 index 0000000..309ed03 --- /dev/null +++ b/docs/reference/icon.rst @@ -0,0 +1,4 @@ +Bootstrap Icons +=============== + +.. automodapi:: bootlace.icon diff --git a/requirements/dev.in b/requirements/dev.in index 4fd11d2..c832694 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -1,5 +1,6 @@ -r tests.in -r typing.in +-r docs.in pip-compile-multi pre-commit tox diff --git a/requirements/dev.txt b/requirements/dev.txt index 70aaf7c..8be5dce 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,10 +1,11 @@ -# SHA1:5ce7dbefd7abca562dec57f2f9ee76a005ccdc85 +# SHA1:2a8909ed753061b404a3b69643af45da9a50e56d # # This file is autogenerated by pip-compile-multi # To update, run: # # pip-compile-multi # +-r docs.txt -r tests.txt -r typing.txt -e file:///Users/alexrudy/Development/alexrudy/bootlace @@ -19,21 +20,15 @@ bump2version==1.0.1 # via -r requirements/dev.in cachetools==5.3.3 # via tox -certifi==2024.2.2 - # via requests cfgv==3.4.0 # via pre-commit chardet==5.2.0 # via tox -charset-normalizer==3.3.2 - # via requests colorama==0.4.6 # via tox distlib==0.3.8 # via virtualenv -docutils==0.20.1 - # via readme-renderer -filelock==3.13.1 +filelock==3.13.2 # via # tox # virtualenv @@ -48,19 +43,21 @@ flake8-implicit-str-concat==0.4.0 # via -r requirements/dev.in flake8-typing-imports==1.15.0 # via -r requirements/dev.in -hatchling==1.22.2 +hatchling==1.22.4 # via -r requirements/dev.in identify==2.5.35 # via pre-commit -idna==3.6 - # via requests -importlib-metadata==7.0.2 +importlib-metadata==7.1.0 # via # keyring # twine jaraco-classes==3.3.1 # via keyring -keyring==24.3.1 +jaraco-context==4.3.0 + # via keyring +jaraco-functools==4.0.0 + # via keyring +keyring==25.0.0 # via twine markdown-it-py==3.0.0 # via rich @@ -69,7 +66,9 @@ mccabe==0.7.0 mdurl==0.1.2 # via markdown-it-py more-itertools==10.2.0 - # via jaraco-classes + # via + # jaraco-classes + # jaraco-functools nh3==0.2.15 # via readme-renderer nodeenv==1.8.0 @@ -89,16 +88,12 @@ platformdirs==4.2.0 # black # tox # virtualenv -pre-commit==3.6.2 +pre-commit==3.7.0 # via -r requirements/dev.in pycodestyle==2.11.1 # via flake8 pyflakes==3.2.0 # via flake8 -pygments==2.17.2 - # via - # readme-renderer - # rich pyproject-api==1.6.1 # via tox pyproject-hooks==1.0.0 @@ -109,10 +104,6 @@ pyyaml==6.0.1 # via pre-commit readme-renderer==43.0 # via twine -requests==2.31.0 - # via - # requests-toolbelt - # twine requests-toolbelt==1.0.0 # via twine rfc3986==2.0.0 @@ -121,16 +112,12 @@ rich==13.7.1 # via twine toposort==1.10 # via pip-compile-multi -tox==4.14.1 +tox==4.14.2 # via -r requirements/dev.in -trove-classifiers==2024.3.3 +trove-classifiers==2024.3.25 # via hatchling twine==5.0.0 # via -r requirements/dev.in -urllib3==2.2.1 - # via - # requests - # twine virtualenv==20.25.1 # via # pre-commit diff --git a/requirements/tests.txt b/requirements/tests.txt index ccad56f..7011cc5 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -18,5 +18,5 @@ pytest==8.1.1 # via # -r requirements/tests.in # pytest-cov -pytest-cov==4.1.0 +pytest-cov==5.0.0 # via -r requirements/tests.in diff --git a/src/bootlace/breadcrumbs.py b/src/bootlace/breadcrumbs.py index 2e3245c..0e3ba6a 100644 --- a/src/bootlace/breadcrumbs.py +++ b/src/bootlace/breadcrumbs.py @@ -18,6 +18,8 @@ from .util import as_tag from .util import is_active_endpoint +__all__ = ["breadcrumbs", "Breadcrumb", "Breadcrumbs", "BreadcrumbEntry", "BreadcrumbExtension", "Endpoint"] + class Named(Protocol): @@ -64,14 +66,21 @@ def __repr__(self) -> str: class Endpoint: """An endpoint for a breadcrumb, as captured at registration""" + #: The flask context, if any context: None | Blueprint + + #: The endpoint name name: str = attrs.field(validator=endpoint_name) + + #: The keyword arguments for the endpoint used with url_for url_kwargs: KeywordArguments = attrs.field(factory=lambda: KeywordArguments(), converter=KeywordArguments) + + #: Whether to ignore the query string when checking for active status ignore_query: bool = True @property def url(self) -> str: - + """The URL for the endpoint""" if isinstance(self.context, Blueprint): name = f"{self.context.name}.{self.name}" return url_for(name, **self.url_kwargs) @@ -80,6 +89,7 @@ def url(self) -> str: @property def active(self) -> bool: + """Whether the endpoint is active""" return is_active_endpoint(self.name, self.url_kwargs, self.ignore_query) def __repr__(self) -> str: @@ -101,17 +111,22 @@ def __repr__(self) -> str: @attrs.define class Breadcrumb: - """A single breadcrumb""" + """A single breadcrumb, representing a single, possibly active, endpoint""" + #: The title of the breadcrumb, displayed in text title: str + + #: The endpoint for the breadcrumb link: Endpoint @property def active(self) -> bool: + """Whether the breadcrumb is the active view""" return self.link.active @property def url(self) -> str: + """The URL for the breadcrumb""" return self.link.url def __tag__(self) -> tags.html_tag: @@ -123,9 +138,14 @@ def __tag__(self) -> tags.html_tag: @attrs.define class Breadcrumbs: - """The trail of breadcrumbs""" + """The trail of breadcrumbs + Supports the :func:`as_tag` protocol to render the breadcrumbs as HTML""" + + #: The list of breadcrumbs, in order from broadest to most specific crumbs: list[Breadcrumb] = attrs.field(factory=list) + + #: The divider to use between breadcrumbs divider: str = attrs.field(default=">") def __iter__(self) -> Iterator[Breadcrumb]: @@ -138,6 +158,7 @@ def __getitem__(self, index: int) -> Breadcrumb: return self.crumbs[index] def push(self, crumb: Breadcrumb) -> None: + """Add a new crumb to the beginning of the list""" self.crumbs.insert(0, crumb) def __tag__(self) -> tags.html_tag: @@ -179,12 +200,25 @@ def __init__(self, app: Flask | None = None) -> None: self.init_app(app) def init_app(self, app: Flask) -> None: + """Set up the extension on the app""" app.config.setdefault(DIVIDER_SETTING, ">") app.extensions[EXTENSION_KEY] = self def register( self, context: Flask | Blueprint | None, parent: str | Endpoint | None, title: str ) -> Callable[[V], V]: + """Register a breadcrumb for a view + + :param context: The context for the view, if any. + For a blueprint, this is the blueprint object. For a view on the root app, + this ie either the root app or None. + :param parent: The parent for the breadcrumb. This can be a string, an endpoint, or None. + If a string, it is the name of the parent endpoint. If an endpoint, it is the parent endpoint. + If None, there is no parent, and this is a root item. + :param title: The title of the breadcrumb + + :returns: A decorator that can be used to register the view, which will return the view unchanged. + """ if isinstance(context, Flask): context = None @@ -213,6 +247,7 @@ def decorator(view: V) -> V: @property def divider(self) -> str: + """The divider to use between breadcrumbs""" return current_app.config[DIVIDER_SETTING] def _current_context(self) -> Blueprint | None: @@ -230,6 +265,7 @@ def _current_endpoint(self) -> Endpoint | None: return Endpoint(name=name, context=context) def get(self) -> Breadcrumbs: + """Get the :class:`Breadcrumbs` for the current request""" endpoint = self._current_endpoint() crumbs = Breadcrumbs(divider=self.divider) if not endpoint: # pragma: no cover diff --git a/src/bootlace/forms/fields.py b/src/bootlace/forms/fields.py index 8dd56ff..4d1467a 100644 --- a/src/bootlace/forms/fields.py +++ b/src/bootlace/forms/fields.py @@ -31,6 +31,13 @@ def _enum_labelfunc(value: E) -> str: class EnumField(fields.SelectField, Generic[E]): + """Field for selecting an enum value. The choices are generated from the enum values. The label is the enum value. + + :param label: The label for the field + :param validators: Validators for the field + :param enum: The enum type + """ + def __init__(self, label: str | None = None, validators: Any = None, *, enum: type[E], **kwargs: Any) -> None: labelfunc = kwargs.pop("labelfunc", _enum_labelfunc) kwargs.setdefault("choices", [(value.name, labelfunc(value)) for value in enum]) @@ -54,6 +61,10 @@ def unwrap_paragraphs(txt: str) -> str: class MarkdownField(fields.TextAreaField): + """TextArea field designed for Markdown content. + + The field will unwrap paragraphs and remove newlines from paragraphs.""" + def _value(self) -> str: if self.data: return unwrap_paragraphs(self.data) @@ -71,6 +82,13 @@ def __init__(self, message: str | None = None) -> None: self.db = mimetypes.MimeTypes() def __call__(self, form: Any, field: fields.Field) -> None: + """Validates the field + + :param form: The form contianing the field + :param field: The field + + :raises ValidationError: If the field is not a known MIME type + """ mimetype, _options = parse_options_header(field.data) well_known_types, official_types = self.db.types_map_inv diff --git a/src/bootlace/forms/widgets.py b/src/bootlace/forms/widgets.py index b4213f8..e9a6bae 100644 --- a/src/bootlace/forms/widgets.py +++ b/src/bootlace/forms/widgets.py @@ -3,6 +3,8 @@ from dominate import tags from wtforms.fields import Field +__all__ = ["Switch"] + class Switch: diff --git a/src/bootlace/icon.py b/src/bootlace/icon.py index d65522d..ba6d18a 100644 --- a/src/bootlace/icon.py +++ b/src/bootlace/icon.py @@ -6,19 +6,34 @@ from flask import url_for +__all__ = ["Icon"] + + @attrs.define class Icon: - """A Bootstrap icon""" + """A Bootstrap icon + + This class supports the :func:`as_tag` protocol to display itself. + """ + #: Endpoint name for getting the Bootstrap Icon SVG file endpoint: ClassVar[str] = "static" + + #: Filename for the Bootstrap Icon SVG file filename: ClassVar[str] = "icons/bootstrap-icons.svg" + #: Name of the icon name: str + + #: Width of the icon width: int = 16 + + #: Height of the icon height: int = 16 @property def url(self) -> str: + """The URL for the SVG source for the icon""" return url_for(self.endpoint, filename=self.filename, _anchor=self.name) def __tag__(self) -> tags.html_tag: From 3502c4ac68f22dee164311af63c1f671f7fc4dbc Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Mon, 25 Mar 2024 18:30:50 +0000 Subject: [PATCH 3/3] Adds documentation for additional reference topics --- docs/api/bootlace.image.Image.rst | 23 ++++++++++ docs/api/bootlace.links.Link.rst | 21 +++++++++ docs/api/bootlace.links.View.rst | 27 +++++++++++ docs/api/bootlace.nav.NavAlignment.rst | 21 +++++++++ docs/api/bootlace.nav.NavStyle.rst | 23 ++++++++++ docs/api/bootlace.nav.elements.Brand.rst | 17 +++++++ docs/api/bootlace.nav.elements.Dropdown.rst | 19 ++++++++ docs/api/bootlace.nav.elements.Link.rst | 37 +++++++++++++++ docs/api/bootlace.nav.elements.Nav.rst | 21 +++++++++ docs/api/bootlace.nav.elements.NavBar.rst | 25 +++++++++++ .../bootlace.nav.elements.NavBarCollapse.rst | 17 +++++++ docs/api/bootlace.nav.elements.NavBarNav.rst | 17 +++++++ .../bootlace.nav.elements.NavBarSearch.rst | 25 +++++++++++ docs/api/bootlace.nav.elements.Separator.rst | 7 +++ docs/api/bootlace.nav.elements.Text.rst | 19 ++++++++ docs/api/bootlace.size.SizeClass.rst | 37 +++++++++++++++ docs/api/bootlace.style.ColorClass.rst | 45 +++++++++++++++++++ docs/api/bootlace.table.CheckColumn.rst | 29 ++++++++++++ docs/api/bootlace.table.Column.rst | 17 +++++++ docs/api/bootlace.table.ColumnBase.rst | 29 ++++++++++++ docs/api/bootlace.table.Datetime.rst | 17 +++++++ docs/api/bootlace.table.Heading.rst | 19 ++++++++ docs/api/bootlace.table.Table.rst | 29 ++++++++++++ docs/api/bootlace.util.BootlaceWarning.rst | 6 +++ docs/api/bootlace.util.Classes.rst | 21 +++++++++ docs/api/bootlace.util.HtmlIDScope.rst | 29 ++++++++++++ docs/api/bootlace.util.IntoTag.rst | 6 +++ docs/api/bootlace.util.MaybeTaggable.rst | 6 +++ docs/api/bootlace.util.Taggable.rst | 7 +++ docs/api/bootlace.util.as_tag.rst | 6 +++ docs/api/bootlace.util.ids.rst | 6 +++ docs/api/bootlace.util.is_active_endpoint.rst | 6 +++ docs/api/bootlace.util.maybe.rst | 6 +++ docs/api/bootlace.util.render.rst | 6 +++ docs/reference.rst | 6 +++ docs/reference/image.rst | 4 ++ docs/reference/layout.rst | 6 +++ docs/reference/link.rst | 4 ++ docs/reference/nav.rst | 7 +++ docs/reference/table.rst | 5 +++ docs/reference/tools.rst | 5 +++ src/bootlace/image.py | 11 +++++ src/bootlace/links.py | 20 +++++++++ src/bootlace/nav/bar.py | 22 +++++++++ src/bootlace/nav/core.py | 16 +++++++ src/bootlace/nav/nav.py | 12 +++++ src/bootlace/size.py | 14 ++++++ src/bootlace/style.py | 29 ++++++++++-- src/bootlace/table/base.py | 13 ++++++ src/bootlace/table/columns.py | 17 +++++++ src/bootlace/util.py | 27 +++++++++++ 51 files changed, 861 insertions(+), 3 deletions(-) create mode 100644 docs/api/bootlace.image.Image.rst create mode 100644 docs/api/bootlace.links.Link.rst create mode 100644 docs/api/bootlace.links.View.rst create mode 100644 docs/api/bootlace.nav.NavAlignment.rst create mode 100644 docs/api/bootlace.nav.NavStyle.rst create mode 100644 docs/api/bootlace.nav.elements.Brand.rst create mode 100644 docs/api/bootlace.nav.elements.Dropdown.rst create mode 100644 docs/api/bootlace.nav.elements.Link.rst create mode 100644 docs/api/bootlace.nav.elements.Nav.rst create mode 100644 docs/api/bootlace.nav.elements.NavBar.rst create mode 100644 docs/api/bootlace.nav.elements.NavBarCollapse.rst create mode 100644 docs/api/bootlace.nav.elements.NavBarNav.rst create mode 100644 docs/api/bootlace.nav.elements.NavBarSearch.rst create mode 100644 docs/api/bootlace.nav.elements.Separator.rst create mode 100644 docs/api/bootlace.nav.elements.Text.rst create mode 100644 docs/api/bootlace.size.SizeClass.rst create mode 100644 docs/api/bootlace.style.ColorClass.rst create mode 100644 docs/api/bootlace.table.CheckColumn.rst create mode 100644 docs/api/bootlace.table.Column.rst create mode 100644 docs/api/bootlace.table.ColumnBase.rst create mode 100644 docs/api/bootlace.table.Datetime.rst create mode 100644 docs/api/bootlace.table.Heading.rst create mode 100644 docs/api/bootlace.table.Table.rst create mode 100644 docs/api/bootlace.util.BootlaceWarning.rst create mode 100644 docs/api/bootlace.util.Classes.rst create mode 100644 docs/api/bootlace.util.HtmlIDScope.rst create mode 100644 docs/api/bootlace.util.IntoTag.rst create mode 100644 docs/api/bootlace.util.MaybeTaggable.rst create mode 100644 docs/api/bootlace.util.Taggable.rst create mode 100644 docs/api/bootlace.util.as_tag.rst create mode 100644 docs/api/bootlace.util.ids.rst create mode 100644 docs/api/bootlace.util.is_active_endpoint.rst create mode 100644 docs/api/bootlace.util.maybe.rst create mode 100644 docs/api/bootlace.util.render.rst create mode 100644 docs/reference/image.rst create mode 100644 docs/reference/layout.rst create mode 100644 docs/reference/link.rst create mode 100644 docs/reference/nav.rst create mode 100644 docs/reference/table.rst create mode 100644 docs/reference/tools.rst diff --git a/docs/api/bootlace.image.Image.rst b/docs/api/bootlace.image.Image.rst new file mode 100644 index 0000000..3698b97 --- /dev/null +++ b/docs/api/bootlace.image.Image.rst @@ -0,0 +1,23 @@ +Image +===== + +.. currentmodule:: bootlace.image + +.. autoclass:: Image + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Image.alt + ~Image.height + ~Image.src + ~Image.width + + .. rubric:: Attributes Documentation + + .. autoattribute:: alt + .. autoattribute:: height + .. autoattribute:: src + .. autoattribute:: width diff --git a/docs/api/bootlace.links.Link.rst b/docs/api/bootlace.links.Link.rst new file mode 100644 index 0000000..e1763ee --- /dev/null +++ b/docs/api/bootlace.links.Link.rst @@ -0,0 +1,21 @@ +Link +==== + +.. currentmodule:: bootlace.links + +.. autoclass:: Link + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Link.active + ~Link.enabled + ~Link.url + + .. rubric:: Attributes Documentation + + .. autoattribute:: active + .. autoattribute:: enabled + .. autoattribute:: url diff --git a/docs/api/bootlace.links.View.rst b/docs/api/bootlace.links.View.rst new file mode 100644 index 0000000..4b67e15 --- /dev/null +++ b/docs/api/bootlace.links.View.rst @@ -0,0 +1,27 @@ +View +==== + +.. currentmodule:: bootlace.links + +.. autoclass:: View + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~View.active + ~View.enabled + ~View.endpoint + ~View.ignore_query + ~View.url + ~View.url_kwargs + + .. rubric:: Attributes Documentation + + .. autoattribute:: active + .. autoattribute:: enabled + .. autoattribute:: endpoint + .. autoattribute:: ignore_query + .. autoattribute:: url + .. autoattribute:: url_kwargs diff --git a/docs/api/bootlace.nav.NavAlignment.rst b/docs/api/bootlace.nav.NavAlignment.rst new file mode 100644 index 0000000..1dbf9ad --- /dev/null +++ b/docs/api/bootlace.nav.NavAlignment.rst @@ -0,0 +1,21 @@ +NavAlignment +============ + +.. currentmodule:: bootlace.nav + +.. autoclass:: NavAlignment + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~NavAlignment.DEFAULT + ~NavAlignment.FILL + ~NavAlignment.JUSTIFIED + + .. rubric:: Attributes Documentation + + .. autoattribute:: DEFAULT + .. autoattribute:: FILL + .. autoattribute:: JUSTIFIED diff --git a/docs/api/bootlace.nav.NavStyle.rst b/docs/api/bootlace.nav.NavStyle.rst new file mode 100644 index 0000000..d3a5ee5 --- /dev/null +++ b/docs/api/bootlace.nav.NavStyle.rst @@ -0,0 +1,23 @@ +NavStyle +======== + +.. currentmodule:: bootlace.nav + +.. autoclass:: NavStyle + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~NavStyle.PILLS + ~NavStyle.PLAIN + ~NavStyle.TABS + ~NavStyle.UNDERLINE + + .. rubric:: Attributes Documentation + + .. autoattribute:: PILLS + .. autoattribute:: PLAIN + .. autoattribute:: TABS + .. autoattribute:: UNDERLINE diff --git a/docs/api/bootlace.nav.elements.Brand.rst b/docs/api/bootlace.nav.elements.Brand.rst new file mode 100644 index 0000000..09b9ba9 --- /dev/null +++ b/docs/api/bootlace.nav.elements.Brand.rst @@ -0,0 +1,17 @@ +Brand +===== + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: Brand + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Brand.id + + .. rubric:: Attributes Documentation + + .. autoattribute:: id diff --git a/docs/api/bootlace.nav.elements.Dropdown.rst b/docs/api/bootlace.nav.elements.Dropdown.rst new file mode 100644 index 0000000..33578d2 --- /dev/null +++ b/docs/api/bootlace.nav.elements.Dropdown.rst @@ -0,0 +1,19 @@ +Dropdown +======== + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: Dropdown + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Dropdown.id + ~Dropdown.title + + .. rubric:: Attributes Documentation + + .. autoattribute:: id + .. autoattribute:: title diff --git a/docs/api/bootlace.nav.elements.Link.rst b/docs/api/bootlace.nav.elements.Link.rst new file mode 100644 index 0000000..3d386f1 --- /dev/null +++ b/docs/api/bootlace.nav.elements.Link.rst @@ -0,0 +1,37 @@ +Link +==== + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: Link + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Link.active + ~Link.enabled + ~Link.id + ~Link.link + ~Link.url + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Link.with_url + ~Link.with_view + + .. rubric:: Attributes Documentation + + .. autoattribute:: active + .. autoattribute:: enabled + .. autoattribute:: id + .. autoattribute:: link + .. autoattribute:: url + + .. rubric:: Methods Documentation + + .. automethod:: with_url + .. automethod:: with_view diff --git a/docs/api/bootlace.nav.elements.Nav.rst b/docs/api/bootlace.nav.elements.Nav.rst new file mode 100644 index 0000000..2137b9f --- /dev/null +++ b/docs/api/bootlace.nav.elements.Nav.rst @@ -0,0 +1,21 @@ +Nav +=== + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: Nav + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Nav.alignment + ~Nav.id + ~Nav.style + + .. rubric:: Attributes Documentation + + .. autoattribute:: alignment + .. autoattribute:: id + .. autoattribute:: style diff --git a/docs/api/bootlace.nav.elements.NavBar.rst b/docs/api/bootlace.nav.elements.NavBar.rst new file mode 100644 index 0000000..e0103b7 --- /dev/null +++ b/docs/api/bootlace.nav.elements.NavBar.rst @@ -0,0 +1,25 @@ +NavBar +====== + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: NavBar + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~NavBar.color + ~NavBar.expand + ~NavBar.fluid + ~NavBar.id + ~NavBar.items + + .. rubric:: Attributes Documentation + + .. autoattribute:: color + .. autoattribute:: expand + .. autoattribute:: fluid + .. autoattribute:: id + .. autoattribute:: items diff --git a/docs/api/bootlace.nav.elements.NavBarCollapse.rst b/docs/api/bootlace.nav.elements.NavBarCollapse.rst new file mode 100644 index 0000000..ca19123 --- /dev/null +++ b/docs/api/bootlace.nav.elements.NavBarCollapse.rst @@ -0,0 +1,17 @@ +NavBarCollapse +============== + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: NavBarCollapse + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~NavBarCollapse.id + + .. rubric:: Attributes Documentation + + .. autoattribute:: id diff --git a/docs/api/bootlace.nav.elements.NavBarNav.rst b/docs/api/bootlace.nav.elements.NavBarNav.rst new file mode 100644 index 0000000..c175dd1 --- /dev/null +++ b/docs/api/bootlace.nav.elements.NavBarNav.rst @@ -0,0 +1,17 @@ +NavBarNav +========= + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: NavBarNav + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~NavBarNav.id + + .. rubric:: Attributes Documentation + + .. autoattribute:: id diff --git a/docs/api/bootlace.nav.elements.NavBarSearch.rst b/docs/api/bootlace.nav.elements.NavBarSearch.rst new file mode 100644 index 0000000..338df9b --- /dev/null +++ b/docs/api/bootlace.nav.elements.NavBarSearch.rst @@ -0,0 +1,25 @@ +NavBarSearch +============ + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: NavBarSearch + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~NavBarSearch.action + ~NavBarSearch.button + ~NavBarSearch.id + ~NavBarSearch.method + ~NavBarSearch.placeholder + + .. rubric:: Attributes Documentation + + .. autoattribute:: action + .. autoattribute:: button + .. autoattribute:: id + .. autoattribute:: method + .. autoattribute:: placeholder diff --git a/docs/api/bootlace.nav.elements.Separator.rst b/docs/api/bootlace.nav.elements.Separator.rst new file mode 100644 index 0000000..85ae0c1 --- /dev/null +++ b/docs/api/bootlace.nav.elements.Separator.rst @@ -0,0 +1,7 @@ +Separator +========= + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: Separator + :show-inheritance: diff --git a/docs/api/bootlace.nav.elements.Text.rst b/docs/api/bootlace.nav.elements.Text.rst new file mode 100644 index 0000000..1bab6fd --- /dev/null +++ b/docs/api/bootlace.nav.elements.Text.rst @@ -0,0 +1,19 @@ +Text +==== + +.. currentmodule:: bootlace.nav.elements + +.. autoclass:: Text + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Text.enabled + ~Text.text + + .. rubric:: Attributes Documentation + + .. autoattribute:: enabled + .. autoattribute:: text diff --git a/docs/api/bootlace.size.SizeClass.rst b/docs/api/bootlace.size.SizeClass.rst new file mode 100644 index 0000000..7922784 --- /dev/null +++ b/docs/api/bootlace.size.SizeClass.rst @@ -0,0 +1,37 @@ +SizeClass +========= + +.. currentmodule:: bootlace.size + +.. autoclass:: SizeClass + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~SizeClass.EXTRA_EXTRA_LARGE + ~SizeClass.EXTRA_LARGE + ~SizeClass.EXTRA_SMALL + ~SizeClass.LARGE + ~SizeClass.MEDIUM + ~SizeClass.SMALL + + .. rubric:: Methods Summary + + .. autosummary:: + + ~SizeClass.add_to_class + + .. rubric:: Attributes Documentation + + .. autoattribute:: EXTRA_EXTRA_LARGE + .. autoattribute:: EXTRA_LARGE + .. autoattribute:: EXTRA_SMALL + .. autoattribute:: LARGE + .. autoattribute:: MEDIUM + .. autoattribute:: SMALL + + .. rubric:: Methods Documentation + + .. automethod:: add_to_class diff --git a/docs/api/bootlace.style.ColorClass.rst b/docs/api/bootlace.style.ColorClass.rst new file mode 100644 index 0000000..0c5f0bd --- /dev/null +++ b/docs/api/bootlace.style.ColorClass.rst @@ -0,0 +1,45 @@ +ColorClass +========== + +.. currentmodule:: bootlace.style + +.. autoclass:: ColorClass + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~ColorClass.BODY + ~ColorClass.DANGER + ~ColorClass.DARK + ~ColorClass.INFO + ~ColorClass.LIGHT + ~ColorClass.PRIMARY + ~ColorClass.SECONDARY + ~ColorClass.SUCCESS + ~ColorClass.TERTIARY + ~ColorClass.WARNING + + .. rubric:: Methods Summary + + .. autosummary:: + + ~ColorClass.add_to_class + + .. rubric:: Attributes Documentation + + .. autoattribute:: BODY + .. autoattribute:: DANGER + .. autoattribute:: DARK + .. autoattribute:: INFO + .. autoattribute:: LIGHT + .. autoattribute:: PRIMARY + .. autoattribute:: SECONDARY + .. autoattribute:: SUCCESS + .. autoattribute:: TERTIARY + .. autoattribute:: WARNING + + .. rubric:: Methods Documentation + + .. automethod:: add_to_class diff --git a/docs/api/bootlace.table.CheckColumn.rst b/docs/api/bootlace.table.CheckColumn.rst new file mode 100644 index 0000000..288b9e4 --- /dev/null +++ b/docs/api/bootlace.table.CheckColumn.rst @@ -0,0 +1,29 @@ +CheckColumn +=========== + +.. currentmodule:: bootlace.table + +.. autoclass:: CheckColumn + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~CheckColumn.no + ~CheckColumn.yes + + .. rubric:: Methods Summary + + .. autosummary:: + + ~CheckColumn.cell + + .. rubric:: Attributes Documentation + + .. autoattribute:: no + .. autoattribute:: yes + + .. rubric:: Methods Documentation + + .. automethod:: cell diff --git a/docs/api/bootlace.table.Column.rst b/docs/api/bootlace.table.Column.rst new file mode 100644 index 0000000..07ffba5 --- /dev/null +++ b/docs/api/bootlace.table.Column.rst @@ -0,0 +1,17 @@ +Column +====== + +.. currentmodule:: bootlace.table + +.. autoclass:: Column + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Column.cell + + .. rubric:: Methods Documentation + + .. automethod:: cell diff --git a/docs/api/bootlace.table.ColumnBase.rst b/docs/api/bootlace.table.ColumnBase.rst new file mode 100644 index 0000000..1d0d6fa --- /dev/null +++ b/docs/api/bootlace.table.ColumnBase.rst @@ -0,0 +1,29 @@ +ColumnBase +========== + +.. currentmodule:: bootlace.table + +.. autoclass:: ColumnBase + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~ColumnBase.attribute + ~ColumnBase.heading + + .. rubric:: Methods Summary + + .. autosummary:: + + ~ColumnBase.cell + + .. rubric:: Attributes Documentation + + .. autoattribute:: attribute + .. autoattribute:: heading + + .. rubric:: Methods Documentation + + .. automethod:: cell diff --git a/docs/api/bootlace.table.Datetime.rst b/docs/api/bootlace.table.Datetime.rst new file mode 100644 index 0000000..f60c8e2 --- /dev/null +++ b/docs/api/bootlace.table.Datetime.rst @@ -0,0 +1,17 @@ +Datetime +======== + +.. currentmodule:: bootlace.table + +.. autoclass:: Datetime + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Datetime.cell + + .. rubric:: Methods Documentation + + .. automethod:: cell diff --git a/docs/api/bootlace.table.Heading.rst b/docs/api/bootlace.table.Heading.rst new file mode 100644 index 0000000..1d208a2 --- /dev/null +++ b/docs/api/bootlace.table.Heading.rst @@ -0,0 +1,19 @@ +Heading +======= + +.. currentmodule:: bootlace.table + +.. autoclass:: Heading + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Heading.icon + ~Heading.text + + .. rubric:: Attributes Documentation + + .. autoattribute:: icon + .. autoattribute:: text diff --git a/docs/api/bootlace.table.Table.rst b/docs/api/bootlace.table.Table.rst new file mode 100644 index 0000000..e90e7e8 --- /dev/null +++ b/docs/api/bootlace.table.Table.rst @@ -0,0 +1,29 @@ +Table +===== + +.. currentmodule:: bootlace.table + +.. autoclass:: Table + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~Table.columns + ~Table.decorated_classes + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Table.__call__ + + .. rubric:: Attributes Documentation + + .. autoattribute:: columns + .. autoattribute:: decorated_classes + + .. rubric:: Methods Documentation + + .. automethod:: __call__ diff --git a/docs/api/bootlace.util.BootlaceWarning.rst b/docs/api/bootlace.util.BootlaceWarning.rst new file mode 100644 index 0000000..838f726 --- /dev/null +++ b/docs/api/bootlace.util.BootlaceWarning.rst @@ -0,0 +1,6 @@ +BootlaceWarning +=============== + +.. currentmodule:: bootlace.util + +.. autoexception:: BootlaceWarning diff --git a/docs/api/bootlace.util.Classes.rst b/docs/api/bootlace.util.Classes.rst new file mode 100644 index 0000000..94b20ec --- /dev/null +++ b/docs/api/bootlace.util.Classes.rst @@ -0,0 +1,21 @@ +Classes +======= + +.. currentmodule:: bootlace.util + +.. autoclass:: Classes + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Classes.add + ~Classes.remove + ~Classes.swap + + .. rubric:: Methods Documentation + + .. automethod:: add + .. automethod:: remove + .. automethod:: swap diff --git a/docs/api/bootlace.util.HtmlIDScope.rst b/docs/api/bootlace.util.HtmlIDScope.rst new file mode 100644 index 0000000..fc9623e --- /dev/null +++ b/docs/api/bootlace.util.HtmlIDScope.rst @@ -0,0 +1,29 @@ +HtmlIDScope +=========== + +.. currentmodule:: bootlace.util + +.. autoclass:: HtmlIDScope + :show-inheritance: + + .. rubric:: Attributes Summary + + .. autosummary:: + + ~HtmlIDScope.scopes + + .. rubric:: Methods Summary + + .. autosummary:: + + ~HtmlIDScope.__call__ + ~HtmlIDScope.factory + + .. rubric:: Attributes Documentation + + .. autoattribute:: scopes + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: factory diff --git a/docs/api/bootlace.util.IntoTag.rst b/docs/api/bootlace.util.IntoTag.rst new file mode 100644 index 0000000..875fb8b --- /dev/null +++ b/docs/api/bootlace.util.IntoTag.rst @@ -0,0 +1,6 @@ +IntoTag +======= + +.. currentmodule:: bootlace.util + +.. autodata:: IntoTag diff --git a/docs/api/bootlace.util.MaybeTaggable.rst b/docs/api/bootlace.util.MaybeTaggable.rst new file mode 100644 index 0000000..f7ae05c --- /dev/null +++ b/docs/api/bootlace.util.MaybeTaggable.rst @@ -0,0 +1,6 @@ +MaybeTaggable +============= + +.. currentmodule:: bootlace.util + +.. autodata:: MaybeTaggable diff --git a/docs/api/bootlace.util.Taggable.rst b/docs/api/bootlace.util.Taggable.rst new file mode 100644 index 0000000..f39ee5a --- /dev/null +++ b/docs/api/bootlace.util.Taggable.rst @@ -0,0 +1,7 @@ +Taggable +======== + +.. currentmodule:: bootlace.util + +.. autoclass:: Taggable + :show-inheritance: diff --git a/docs/api/bootlace.util.as_tag.rst b/docs/api/bootlace.util.as_tag.rst new file mode 100644 index 0000000..3b48246 --- /dev/null +++ b/docs/api/bootlace.util.as_tag.rst @@ -0,0 +1,6 @@ +as_tag +====== + +.. currentmodule:: bootlace.util + +.. autofunction:: as_tag diff --git a/docs/api/bootlace.util.ids.rst b/docs/api/bootlace.util.ids.rst new file mode 100644 index 0000000..9c450c7 --- /dev/null +++ b/docs/api/bootlace.util.ids.rst @@ -0,0 +1,6 @@ +ids +=== + +.. currentmodule:: bootlace.util + +.. autodata:: ids diff --git a/docs/api/bootlace.util.is_active_endpoint.rst b/docs/api/bootlace.util.is_active_endpoint.rst new file mode 100644 index 0000000..53b7735 --- /dev/null +++ b/docs/api/bootlace.util.is_active_endpoint.rst @@ -0,0 +1,6 @@ +is_active_endpoint +================== + +.. currentmodule:: bootlace.util + +.. autofunction:: is_active_endpoint diff --git a/docs/api/bootlace.util.maybe.rst b/docs/api/bootlace.util.maybe.rst new file mode 100644 index 0000000..dd84f83 --- /dev/null +++ b/docs/api/bootlace.util.maybe.rst @@ -0,0 +1,6 @@ +maybe +===== + +.. currentmodule:: bootlace.util + +.. autofunction:: maybe diff --git a/docs/api/bootlace.util.render.rst b/docs/api/bootlace.util.render.rst new file mode 100644 index 0000000..4835481 --- /dev/null +++ b/docs/api/bootlace.util.render.rst @@ -0,0 +1,6 @@ +render +====== + +.. currentmodule:: bootlace.util + +.. autofunction:: render diff --git a/docs/reference.rst b/docs/reference.rst index 139a1b9..72cfc80 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -6,3 +6,9 @@ API Reference reference/breadcrumbs reference/forms reference/icon + reference/image + reference/link + reference/nav + reference/layout + reference/table + reference/tools diff --git a/docs/reference/image.rst b/docs/reference/image.rst new file mode 100644 index 0000000..4e575e2 --- /dev/null +++ b/docs/reference/image.rst @@ -0,0 +1,4 @@ +Images +====== + +.. automodapi:: bootlace.image diff --git a/docs/reference/layout.rst b/docs/reference/layout.rst new file mode 100644 index 0000000..8e38662 --- /dev/null +++ b/docs/reference/layout.rst @@ -0,0 +1,6 @@ +Layout, sizing and colors +========================= + +.. automodapi:: bootlace.style + +.. automodapi:: bootlace.size diff --git a/docs/reference/link.rst b/docs/reference/link.rst new file mode 100644 index 0000000..5bed212 --- /dev/null +++ b/docs/reference/link.rst @@ -0,0 +1,4 @@ +Links +===== + +.. automodapi:: bootlace.links diff --git a/docs/reference/nav.rst b/docs/reference/nav.rst new file mode 100644 index 0000000..008b693 --- /dev/null +++ b/docs/reference/nav.rst @@ -0,0 +1,7 @@ +Navigation +========== + +.. automodapi:: bootlace.nav + +.. automodapi:: bootlace.nav.elements + :allowed-package-names: bootlace.nav diff --git a/docs/reference/table.rst b/docs/reference/table.rst new file mode 100644 index 0000000..f0df752 --- /dev/null +++ b/docs/reference/table.rst @@ -0,0 +1,5 @@ +Tables +====== + +.. automodapi:: bootlace.table + :allowed-package-names: bootlace.table diff --git a/docs/reference/tools.rst b/docs/reference/tools.rst new file mode 100644 index 0000000..bca2b71 --- /dev/null +++ b/docs/reference/tools.rst @@ -0,0 +1,5 @@ +Tools and Utilities +=================== + +.. automodapi:: bootlace.util + :include-all-objects: diff --git a/src/bootlace/image.py b/src/bootlace/image.py index 8b87e7f..751ea21 100644 --- a/src/bootlace/image.py +++ b/src/bootlace/image.py @@ -1,12 +1,23 @@ import attrs from dominate import tags +__all__ = ["Image"] + @attrs.define(kw_only=True, frozen=True) class Image: + """An image tag""" + + #: Alt text for the image alt: str + + #: The URL for the image src: str + + #: The width of the image, in px width: int + + #: The height of the image, in px height: int def __tag__(self) -> tags.html_tag: diff --git a/src/bootlace/links.py b/src/bootlace/links.py index 9929fde..a37b036 100644 --- a/src/bootlace/links.py +++ b/src/bootlace/links.py @@ -9,6 +9,8 @@ from .util import is_active_endpoint from .util import MaybeTaggable +__all__ = ["Link", "View"] + @attrs.define(kw_only=True, frozen=True) class LinkBase(abc.ABC): @@ -33,22 +35,40 @@ def __tag__(self) -> tags.html_tag: @attrs.define(kw_only=True, frozen=True) class Link(LinkBase): + """A raw link to a URL.""" + + #: The URL to link to url: str + + #: Whether the link is active active: bool = False + + #: Whether the link is enabled enabled: bool = True @attrs.define(kw_only=True, frozen=True) class View(LinkBase): + """Link to a Flask view.""" + + #: The endpoint to link to, for use with Flask's :func:`~flask.url_for` endpoint: str + + #: The keyword arguments to pass to :func:`~flask.url_for` url_kwargs: dict[str, Any] = attrs.field(factory=dict) + + #: Whether to ignore the query string when checking if the link is active ignore_query: bool = True + + #: Whether the link is enabled. enabled: bool = True @property def url(self) -> str: + """The URL to link to, constructed using :func:`~flask.url_for`.""" return url_for(self.endpoint, **self.url_kwargs) @property def active(self) -> bool: + """Whether the link is active, based on the current request endpoint.""" return is_active_endpoint(self.endpoint, self.url_kwargs, self.ignore_query) diff --git a/src/bootlace/nav/bar.py b/src/bootlace/nav/bar.py index d96b7de..f545b49 100644 --- a/src/bootlace/nav/bar.py +++ b/src/bootlace/nav/bar.py @@ -14,10 +14,25 @@ @attrs.define class NavBar(NavElement): + """A navigation bar, typically at the top of the page + + This is usually the primary navigation for a site. + """ + + #: The ID of the navbar id: str = attrs.field(factory=element_id.factory("navbar")) + + #: The elements in the navbar items: list[NavElement] = attrs.field(factory=list) + + #: The size of the navbar, if any, used to select when it + #: should expand or collapse expand: SizeClass | None = SizeClass.LARGE + + #: The color of the navbar, if using a bootstrap color class color: ColorClass | None = ColorClass.TERTIARY + + #: Whether the navbar should be fluid (e.g. full width) fluid: bool = True def __tag__(self) -> tags.html_tag: @@ -43,6 +58,13 @@ def __tag__(self) -> tags.html_tag: @attrs.define class Brand(Link): + """The brand for the navbar, typically the site's logo or name + + You can pass :class:`~bootlace.links.Link` or :class:`~bootlace.links.View` + as the source link, and + """ + + #: The ID of the brand id: str = attrs.field(factory=element_id.factory("navbar-brand")) def __tag__(self) -> tags.html_tag: diff --git a/src/bootlace/nav/core.py b/src/bootlace/nav/core.py index 15aef86..01e5dbd 100644 --- a/src/bootlace/nav/core.py +++ b/src/bootlace/nav/core.py @@ -34,10 +34,12 @@ class NavElement: @property def active(self) -> bool: + """Whether the element is active""" return False @property def enabled(self) -> bool: + """Whether the element is enabled""" return True def __tag__(self) -> tags.html_tag: @@ -45,6 +47,7 @@ def __tag__(self) -> tags.html_tag: return tags.comment(f"unhandled element {self.__class__.__name__}") def element_state(self, tag: tags.html_tag) -> tags.html_tag: + """Apply :attr:`active` and :attr:`enabled` states to the tag.""" if self.active: tag.classes.add("active") tag.attributes["aria-current"] = "page" @@ -57,28 +60,37 @@ def element_state(self, tag: tags.html_tag) -> tags.html_tag: @attrs.define class Link(NavElement): + """A link in the nav bar, either for a view or a literal URL""" + #: The link to display, either a URL or a view link: links.LinkBase + + #: The ID of the element id: str = attrs.field(factory=element_id.factory("nav-link")) @classmethod def with_url(cls, url: str, text: str | Image, **kwargs: Any) -> "Link": + """Create a link with a URL.""" return cls(link=links.Link(url=url, text=text, **kwargs)) @classmethod def with_view(cls, endpoint: str, text: str | Image, **kwargs: Any) -> "Link": + """Create a link with a view.""" return cls(link=links.View(endpoint=endpoint, text=text, **kwargs)) @property def active(self) -> bool: + """Whether the link is active.""" return self.link.active @property def enabled(self) -> bool: + """Whether the link is enabled.""" return self.link.enabled @property def url(self) -> str: + """The URL for the link.""" return self.link.url def __tag__(self) -> tags.html_tag: @@ -91,6 +103,7 @@ def __tag__(self) -> tags.html_tag: @attrs.define class Separator(NavElement): + """A separator in dropdown menus""" def __tag__(self) -> tags.html_tag: return tags.hr(cls="dropdown-divider") @@ -98,6 +111,7 @@ def __tag__(self) -> tags.html_tag: @attrs.define class Text(NavElement): + """A text element in the nav bar""" text: str @@ -112,6 +126,8 @@ def __tag__(self) -> tags.html_tag: @attrs.define class SubGroup(NavElement): + """Any grouping of items in the nav bar""" + items: list[NavElement] = attrs.field(factory=list) @property diff --git a/src/bootlace/nav/nav.py b/src/bootlace/nav/nav.py index c22fa3f..3f30a0f 100644 --- a/src/bootlace/nav/nav.py +++ b/src/bootlace/nav/nav.py @@ -10,8 +10,15 @@ @attrs.define class Nav(SubGroup): + """A navigation bar""" + + #: The ID of the nav id: str = attrs.field(factory=element_id.factory("nav")) + + #: The style of the nav style: NavStyle = NavStyle.PLAIN + + #: The alignment of the elments in the nav alignment: NavAlignment = NavAlignment.DEFAULT def __tag__(self) -> tags.html_tag: @@ -36,7 +43,12 @@ def __tag__(self) -> tags.html_tag: @attrs.define class Dropdown(SubGroup): + """A dropdown menu in the nav bar""" + + #: The title of the dropdown title: str = attrs.field(kw_only=True) + + #: The ID of the dropdown id: str = attrs.field(factory=element_id.factory("bs-dropdown")) def __tag__(self) -> tags.html_tag: diff --git a/src/bootlace/size.py b/src/bootlace/size.py index f47ed37..53add65 100644 --- a/src/bootlace/size.py +++ b/src/bootlace/size.py @@ -2,14 +2,28 @@ class SizeClass(enum.Enum): + """Bootstrap size classes""" + + #: Extra-small is the default size class used when none is specified. < 576px EXTRA_SMALL = None + + #: Small size class <768px SMALL = "sm" + + #: Medium size class <992px MEDIUM = "md" + + #: Large size class <1200px LARGE = "lg" + + #: Extra-large size class <1400px EXTRA_LARGE = "xl" + + #: Extra-extra-large size class >=1400px EXTRA_EXTRA_LARGE = "xxl" def add_to_class(self, cls: str) -> str: + """Add the size class to the given class.""" if self.value: return f"{cls}-{self.value}" else: diff --git a/src/bootlace/style.py b/src/bootlace/style.py index 1932ee5..376cef3 100644 --- a/src/bootlace/style.py +++ b/src/bootlace/style.py @@ -2,17 +2,40 @@ class ColorClass(enum.Enum): + """Bootstrap color classes""" + + #: Default foreground (color) and background, including components. + BODY = None + + #: Main theme color, used for hyperlinks, focus styles, and component and form active states. PRIMARY = "primary" + + #: Secondary theme color, used for secondary buttons and form elements. SECONDARY = "secondary" + + #: Tertiary theme color, used for tertiary buttons and form elements. TERTIARY = "tertiary" + + #: Success state color, used for success messages and indicators. SUCCESS = "success" + + #: Danger state color, used for error messages and indicators. DANGER = "danger" + + #: Warning state color, used for warning messages and indicators. WARNING = "warning" + + #: Info state color, used for informational messages and indicators. INFO = "info" + + #: Additional theme option for less contrasting colors. LIGHT = "light" + + #: Additional theme option for higher contrasting colors. DARK = "dark" - WHITE = "white" - TRANSPARENT = "transparent" def add_to_class(self, cls: str) -> str: - return f"{cls}-{self.value}" + """Add the color class name to the given class.""" + if self.value: + return f"{cls}-{self.value}" + return cls diff --git a/src/bootlace/table/base.py b/src/bootlace/table/base.py index 097affd..bf1028e 100644 --- a/src/bootlace/table/base.py +++ b/src/bootlace/table/base.py @@ -16,7 +16,12 @@ @attrs.define class Heading: + """A heading for a table column.""" + + #: The text of the heading text: str + + #: The icon for the heading, in place of the text icon: Icon | None = attrs.field(default=None, converter=maybe(Icon)) # type: ignore def __tag__(self) -> tags.html_tag: @@ -29,7 +34,13 @@ def __tag__(self) -> tags.html_tag: @attrs.define class ColumnBase(ABC): + """Base class for table columns. + + Subclasses must implement the :meth:`cell` method.""" + + #: The heading for the column heading: Heading = attrs.field(converter=maybe(Heading)) # type: ignore + _attribute: str | None = None def __set_name__(self, owner: type, name: str) -> None: @@ -37,12 +48,14 @@ def __set_name__(self, owner: type, name: str) -> None: @property def attribute(self) -> str: + """The attribute name for the column.""" if self._attribute is None: raise ValueError("column must be named in Table or attribute= parameter must be provided") return self._attribute @abstractmethod def cell(self, value: Any) -> tags.html_tag: + """Return the cell for the column as an HTML tag.""" raise NotImplementedError("Subclasses must implement this method") diff --git a/src/bootlace/table/columns.py b/src/bootlace/table/columns.py index 0d883ce..da3a10c 100644 --- a/src/bootlace/table/columns.py +++ b/src/bootlace/table/columns.py @@ -15,27 +15,42 @@ @attrs.define class Column(ColumnBase): + """A column in a table, which shows the value of an attribute. + + No special formatting is applied to the attribute, it is rendered as text.""" def cell(self, value: Any) -> tags.html_tag: + """Return the cell for the column as an HTML tag.""" return text(str(getattr(value, self.attribute))) @attrs.define class EditColumn(ColumnBase): + """A column which links to an edit view for the value. + + This is commonly shown as e.g. the name of the item, which links to the edit view.""" + + #: The endpoint for the edit view endpoint: str = attrs.field(default=".edit") def cell(self, value: Any) -> tags.html_tag: + """Return the cell for the column as an HTML tag.""" id = getattr(value, "id", None) return tags.a(getattr(value, self.attribute), href=url_for(self.endpoint, id=id)) @attrs.define class CheckColumn(ColumnBase): + """A column which shows a checkmark or X based on the value of the attribute.""" + #: The icon for a true value yes: Icon = attrs.field(default=Icon("check", width=16, height=16)) + + #: The icon for a false value no: Icon = attrs.field(default=Icon("x", width=16, height=16)) def cell(self, value: Any) -> tags.html_tag: + """Return the cell for the column as an HTML tag.""" if getattr(value, self.attribute): return as_tag(self.yes) return as_tag(self.no) @@ -43,6 +58,8 @@ def cell(self, value: Any) -> tags.html_tag: @attrs.define class Datetime(ColumnBase): + """A column which shows a datetime attribute as an ISO formatted string.""" def cell(self, value: Any) -> tags.html_tag: + """Return the cell for the column as an HTML tag.""" return text(getattr(value, self.attribute).isoformat()) diff --git a/src/bootlace/util.py b/src/bootlace/util.py index 4e28639..c67164e 100644 --- a/src/bootlace/util.py +++ b/src/bootlace/util.py @@ -19,6 +19,20 @@ T = TypeVar("T") +__all__ = [ + "BootlaceWarning", + "Classes", + "HtmlIDScope", + "IntoTag", + "MaybeTaggable", + "Taggable", + "as_tag", + "ids", + "is_active_endpoint", + "maybe", + "render", +] + class BootlaceWarning(UserWarning): """A warning specific to Bootlace""" @@ -30,15 +44,21 @@ def _monkey_patch_dominate() -> None: class Taggable(Protocol): + """Protocol for objects that can be converted to a tag.""" + def __tag__(self) -> tags.html_tag: ... +#: A type that can be converted to a tag IntoTag = Taggable | tags.html_tag +#: A type that can be converted to a tag via :func:`as_tag` MaybeTaggable = IntoTag | str | Iterable[Taggable | tags.html_tag] def as_tag(item: Taggable) -> tags.html_tag: + """Convert an item to a dominate tag.""" + if isinstance(item, tags.html_tag): return item if hasattr(item, "__tag__"): @@ -53,10 +73,13 @@ def as_tag(item: Taggable) -> tags.html_tag: def render(item: Taggable) -> Markup: + """Render an item to a Markup object.""" return Markup(as_tag(item).render()) class Classes: + """A helper for manipulating the class attribute on a tag.""" + def __init__(self, tag: tags.html_tag) -> None: self.tag = tag @@ -94,6 +117,8 @@ def swap(self, old: str, new: str) -> tags.html_tag: @attrs.define class HtmlIDScope: + """A helper for generating unique HTML IDs.""" + scopes: collections.defaultdict[str, itertools.count] = attrs.field( factory=lambda: collections.defaultdict(itertools.count) ) @@ -112,6 +137,8 @@ def factory(self, scope: str) -> functools.partial: def maybe(cls: type[T]) -> Callable[[str | T], T]: + """Convert a string to a class instance if necessary.""" + def converter(value: str | T) -> T: if isinstance(value, str): return cls(value) # type: ignore