From e59d769daca1307e3a75101603f121b211d1b370 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Wed, 10 May 2017 10:58:51 +0200 Subject: [PATCH] Doc for scss --- README.md | 6 ++++-- core/management/commands/compilestatic.py | 3 +++ core/scss/processor.py | 5 +++++ core/templatetags/renderer.py | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b0c2b1d..654d37d7 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,11 @@ The development is done with sqlite, but it is advised to set a more robust DBMS ### Collecting statics for production: +We use scss in the project. In development environment (DEBUG=True), scss is compiled every time the file is needed. For production, it assumes you have already compiled every files and to do so, you need to use the following commands : + ``` -./manage.py collectstatic -./manage.py compilestatic +./manage.py collectstatic # To collect statics +./manage.py compilestatic # To compile scss in those statics ``` ### Misc about development diff --git a/core/management/commands/compilestatic.py b/core/management/commands/compilestatic.py index 45e84576..0d96c8ea 100644 --- a/core/management/commands/compilestatic.py +++ b/core/management/commands/compilestatic.py @@ -30,6 +30,9 @@ from django.conf import settings class Command(BaseCommand): + """ + Compiles scss in static folder for production + """ help = "Compile scss files from static folder" def compile(self, filename): diff --git a/core/scss/processor.py b/core/scss/processor.py index 54b82b4b..dab0de4c 100644 --- a/core/scss/processor.py +++ b/core/scss/processor.py @@ -34,6 +34,11 @@ from core.scss.storage import ScssFileStorage, find_file class ScssProcessor(object): + """ + If DEBUG mode enabled : compile the scss file + Else : give the path of the corresponding css supposed to already be compiled + Don't forget to use compilestatics to compile scss for production + """ prefix = iri_to_uri(getattr(settings, 'STATIC_URL', '/static/')) storage = ScssFileStorage() scss_extensions = [".scss"] diff --git a/core/templatetags/renderer.py b/core/templatetags/renderer.py index 5fc63458..23ae8d03 100644 --- a/core/templatetags/renderer.py +++ b/core/templatetags/renderer.py @@ -53,5 +53,8 @@ def datetime_format_python_to_PHP(python_format_string): @register.simple_tag() def scss(path): + """ + Return path of the corresponding css file after compilation + """ processor = ScssProcessor(path) return processor.get_converted_scss() \ No newline at end of file