@@ -53,24 +53,65 @@ Syntax and conventions
53
53
Python
54
54
------
55
55
56
- We try to conform to `PEP8 `_ as much as possible. A few highlights:
56
+ We try to conform to `PEP8 `_ as much as possible. New code must follow the ruff
57
+ formatter (and the pre-commit hook will ensure this). A few highlights:
57
58
58
- - Indentation should be exactly 4 spaces. Not 2, not 6, not 8. **4 **. Also, tabs
59
- are evil.
60
- - We try (loosely) to keep the line length at 79 characters. Generally the rule
61
- is "it should look good in a terminal-base editor" (eg vim), but we try not be
62
- too inflexible about it.
59
+ - **Line Length **: Default is 119 characters.
63
60
61
+ - **Indentation **: 4 spaces per indentation level; not more, not less.
64
62
65
- HTML, CSS and JavaScript
66
- ------------------------
63
+ - **Quotes **: We use double quotes (`" `).
67
64
68
- As of django CMS 3.2, we are using the same guidelines as described in `Aldryn
69
- Boilerplate `_
65
+ - **Trailing Commas **: Included where syntactically valid, such as in function arguments and list literals.
70
66
71
- Frontend code should be formatted for readability. If in doubt, follow existing
72
- examples, or ask.
67
+ - **Function Definitions **: Parameters are each on their own line if the function signature spans multiple lines.
73
68
69
+ - **Docstrings **: Single-line docstrings use double quotes and are formatted with consistent indentation.
70
+
71
+ - **Blank Lines **: Two blank lines before top-level definitions; one blank line between methods inside a class.
72
+
73
+ - **Imports **: Grouped and ordered: standard library, third-party, then local imports. Each group is separated by a blank line.
74
+
75
+
76
+ HTML
77
+ ----
78
+
79
+ - **Naming **: Use clear, meaningful names.
80
+ - **Indentation **: 4 spaces, no tabs.
81
+ - **IDs vs Classes **: Prefer classes.
82
+ - **Modularity **: Create reusable components.
83
+
84
+ CSS
85
+ ---
86
+
87
+ - **Naming **: Follow `BEM (Block Element Modifier) <http://getbem.com/ >`_.
88
+ - **Nesting **: Keep Sass nesting shallow (1–2 levels).
89
+ - **Formatting **:
90
+ - 4 spaces indentation.
91
+ - One selector per line.
92
+ - Lowercase properties/values (unless uppercase is needed).
93
+ - **Ordering **:
94
+ 1. Positioning
95
+ 2. Box model
96
+ 3. Typography
97
+ 4. Visual
98
+ 5. Miscellaneous
99
+
100
+ JavaScript
101
+ ----------
102
+
103
+ - **Naming **:
104
+ - `camelCase ` for variables/functions
105
+ - `PascalCase ` for classes
106
+ - `UPPER_CASE ` for constants
107
+ - **Formatting **:
108
+ - 4 spaces indentation
109
+ - Always use semicolons
110
+ - Use single quotes (unlike Python quotes!)
111
+ - **Implementation **:
112
+ - Wrap code in IIFEs
113
+ - Use `'use strict'; `
114
+ - **Patterns **: Prefer modular, reusable patterns.
74
115
75
116
.. _js_linting :
76
117
0 commit comments