Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
feat: project refactoring & cookiecutter support (#6)
Browse files Browse the repository at this point in the history
* feat: "enlarge" docs theme
* feat: project restructure, cookiecutter support
* feat: signal (known as "plugin" in the past) strong type-hint
* feat: cookiecutter hooks
* feat: cookiecutter documentation
* feat: UI
* feat: cookiecutter copy without render
* feat: cookiecutter user config support
  • Loading branch information
Lydia committed May 27, 2023
1 parent 46ba993 commit d30eef4
Show file tree
Hide file tree
Showing 64 changed files with 3,680 additions and 3,095 deletions.
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ repos:
- id: check-case-conflict
- id: check-merge-conflict

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/compilerla/conventional-pre-commit
rev: v1.3.0
hooks:
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ Documentation: <https://fabricius.readthedocs.io>

> :warning: Fabricius still does not comes with it's CLI tool! It is a work in progress!
## 👀 How about checking out the `development` branch?

This branch has been silent for quite a while now, you might believe the project is dead. **IT'S NOT!**
The true magic is happening behind the scene, available in the `development` branch! If you want to see how things are working out for Fabricius, you should check the stuff out there!

The `master` is here to represent the version of Fabricius that is available on PyPi (As of today, `0.1.0`)

## Goals:

1. Create a working project from a project template
Expand Down
2 changes: 2 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
livehtml:
sphinx-autobuild --watch . --watch ../fabricius "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

Expand Down
7 changes: 0 additions & 7 deletions docs/modules.rst

This file was deleted.

40 changes: 40 additions & 0 deletions docs/source/_static/furo_custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Ok... So what did we do here?
* Nothing much honestly, we "expanded" Furo. I thought it was really a shame it wasn't using
* the full place of the screen (Most especially for API docs), so the sidebar will now be mostly
* present on the side and not take an enormeous place for nothing, and the docs's content will
* take 80% of the screen now (Instead of a ridiculous 40% IMO).
*/

.sidebar-drawer {
width: auto;
}

.content {
width: auto;
}

.toc-drawer {
display: flex;
flex: none;
}

@media (max-width: 82em) {
.toc-drawer {
border-left: initial;
height: initial;
position: initial;
right: initial;
top: initial;
}
}

@media (max-width: 52em) {
.toc-drawer {
border-left: 1px solid var(--color-background-muted);
height: 100vh;
position: fixed;
right: -15em;
top: 0;
}
}
4 changes: 0 additions & 4 deletions docs/source/about_generator.rst

This file was deleted.

7 changes: 7 additions & 0 deletions docs/source/api/exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Exceptions
==========

Inside all of our logic behind it, we have created supplementary exceptions to explain what could have gone wrong either in your template, or potentially what could have badly happened.

.. automodule:: fabricius.exceptions
:members:
21 changes: 0 additions & 21 deletions docs/source/api/fabricius.generator.rst

This file was deleted.

29 changes: 0 additions & 29 deletions docs/source/api/fabricius.plugins.rst

This file was deleted.

86 changes: 0 additions & 86 deletions docs/source/api/fabricius.rst

This file was deleted.

23 changes: 23 additions & 0 deletions docs/source/api/models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Models
======

Models represents the objects used inside Fabricius, for example, the :py:class:`File <fabricius.models.file.File>` model is an object that represent a file we're about to create.

In this page, you're able to visit the available methods in our models and freely uses them.


.. autoclass:: fabricius.models.file.File
:members:


.. autoclass:: fabricius.models.signal.Signal
:members:


.. autoclass:: fabricius.models.renderer.Renderer
:members:


.. autoclass:: fabricius.models.template.Template
:members:
:undoc-members:
12 changes: 0 additions & 12 deletions docs/source/api/modules.rst

This file was deleted.

37 changes: 37 additions & 0 deletions docs/source/api/renderers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Renderers
=========

The "Renderer" is a class that is created in order to generate the content of a template.

Fabricius ships many by default, you can use them, or create your own if you feel the need to.

.. code-block:: py
from fabricius.renderers import Renderer
class MyRenderer(Renderer):
# You must implement the "render" method, this will be called by Fabricius.
def render(self, content: str):
# Inside of the Renderer class, the "data" property is available.
# This is where the data is stored.
final_content = render_content(content=content, data=self.data)
return final_content
renderer = MyRenderer({"name": "John"})
final_content = renderer.render("Hello {{ name }}")
print(final_content)
# Hello John
The following is the list of the available renderer packaged with Fabricius. It contains Python's str.format, string template, Mustache & Jinja.

.. hint::

If you're using the :py:class:`File <fabricius.models.file.File>` object, you can use methods :py:meth:`File.use_jinja() <fabricius.models.file.File.use_jinja>` to set the renderer to one of Fabricius's available.
To use your own Renderer, use :py:meth:`File.with_renderer() <fabricius.models.file.File.with_renderer>`.

.. automodule:: fabricius.renderers
:members:
:imported-members:
64 changes: 64 additions & 0 deletions docs/source/api/signals.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Signals
=======

Signals are `observers <https://refactoring.guru/design-patterns/observer>`_.
They permit you to run code when a specific action is happening.

There is a lot of signal that Fabricius raises so you can subscribe to any thing you'd like.
For example, before committing a file, you can add a suffix to its name before it get committed.

.. code-block:: py
from fabricius.app.signals import before_file_commit
from fabricius.models.file import File
on_file_commit(file: File):
file.name = f"{file.name}.template"
before_file_commit.connect(on_file_commit)
Here is a list of the available signals raised in Fabricius.

.. automodule:: fabricius.app.signals
:members:


Create your own signals
-----------------------

You can create your own signal by creating a :py:class:`fabricius.models.signal.Signal` object and letting it available in your project.

.. code-block:: py
from fabricius.models.signal import Signal
my_signal = Signal()
While this is totally OK to go like this, you can also optionally type the :py:meth:`.send() <fabricius.models.signal.Signal.connect>`/:py:meth:`.connect() <fabricius.models.signal.Signal.connect>` methods by providing a function.
Fabricius will extract the function's signature and use it to transfer the arguments into the signal's methods.

.. code-block:: py
from fabricius.models.file import File
from fabricius.models.signal import Signal
def my_signal_hint(file: File):
...
my_signal = Signal(func_hint=my_signal_hint)
my_signal.send(File("test.py")) # This is OK
my_signal.send() # This is not! Your type checker will complain!
# Good
def signal_receiver(file: File):
...
my_signal.connect(signal_receiver)
# Bad
def signal_receiver(receiving_file: File):
...
my_signal.connect(signal_receiver)
# This will raise a type error if the function's signature is altered
# (New, removed, renamed arguments, etc...)
13 changes: 13 additions & 0 deletions docs/source/api/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Types
=====

This page is fairly short, but deserves to be shown.

This explains you the specific types available in Fabricius.
They are widely used inside Fabricius in order to simply how the docs is rendered and to facilitate understanding of the library.


Fabricius types

.. automodule:: fabricius.types
:members:

0 comments on commit d30eef4

Please sign in to comment.