This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: project refactoring & cookiecutter support (#6)
* 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
Showing
64 changed files
with
3,680 additions
and
3,095 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: |
Oops, something went wrong.