Skip to content

Commit 6b529d2

Browse files
authored
Merge pull request #814 from roland04/scss-deprecation
[docs] Add SCSS deprecation page
2 parents a5db243 + a256a03 commit 6b529d2

File tree

7 files changed

+132
-11
lines changed

7 files changed

+132
-11
lines changed

data/migratedPages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Debugging_network_requests_in_the_Moodle_App:
173173
- filePath: "/general/app/development/network-debug.md"
174174
slug: "/general/app/development/network-debug"
175175
Deprecation:
176-
- filePath: "/general/development/policies/deprecation.md"
176+
- filePath: "/general/development/policies/deprecation/index.md"
177177
slug: "/general/development/policies/deprecation"
178178
Designing_usable_forms:
179179
- filePath: "/general/development/policies/designing-usable-forms.md"

general/development/policies/codingstyle/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ If you have a big task that is nearly done, apart a few TODOs, and you really wa
20282028

20292029
There is a nice "to-do checker" reporting tool, restricted to admins and available via web @ [`lib/tests/other/todochecker.php`](https://github.com/moodle/moodle/blob/master/lib/tests/other/todochecker.php).
20302030

2031-
Finally, don't forget to add any MDL-12345 used by your TODOs (and @todos too, unless part of the [deprecation process](../deprecation.md), those are handled apart) to the "Review TODOs Epic": MDL-47779 (requires login to see the issues)
2031+
Finally, don't forget to add any MDL-12345 used by your TODOs (and @todos too, unless part of the [deprecation process](../deprecation/index.md), those are handled apart) to the "Review TODOs Epic": MDL-47779 (requires login to see the issues)
20322032

20332033
### CVS keywords
20342034

general/development/policies/deprecation.md renamed to general/development/policies/deprecation/index.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Both steps should always happen as earlier as possible in the 6-months period be
3838

3939
### Step 1. Immediate action
4040

41-
Deprecation affects only the current master version, in other words, the deprecation only becomes effective after the next [major release](../../releases.md).
41+
Deprecation affects only the current master version, in other words, the deprecation only becomes effective after the next [major release](../../../releases.md).
4242

4343
- If the function is not a member of a class (in other words, it is an independent function), it should be moved, with its PHPDoc and all comments, to `lib/deprecatedlib.php`, which is included everywhere. If the function is a class member, it will need to be deprecated in its current location.
4444
- Deprecated behat step definitions should be moved to `lib/tests/behat/behat_deprecated.php`, including a call to `behat_deprecated::deprecated_message()` proposing an alternative to the deprecated method.
@@ -54,7 +54,7 @@ Deprecation affects only the current master version, in other words, the depreca
5454
```
5555

5656
- If the deprecated function has been replaced with a new function, ideally the new function should be called from the deprecated function, so that the new functionality is used. This will make maintenance easier moving forward.
57-
- A `@deprecated` tag should be added to the PHPDoc for the function description so that IDEs describing the function will note that it is deprecated, documenting which version it was deprecated in and the MDL issue associated with it. See the guidelines in [Coding style](./codingstyle/index.md#deprecated-and-todo).
57+
- A `@deprecated` tag should be added to the PHPDoc for the function description so that IDEs describing the function will note that it is deprecated, documenting which version it was deprecated in and the MDL issue associated with it. See the guidelines in [Coding style](../codingstyle/index.md#deprecated-and-todo).
5858
- If the function is an external function, then an additional deprecation-specific method needs to be created and set to return true. See the [adding a web service to a plugin](/docs/apis/subsystems/external/writing-a-service#deprecation) docs on that process. You should continue to add the `@deprecated since x.x` tag to the docs of all three of the relevant external methods (parameters, main method, returns) to make it clear to IDEs that the function is deprecated.
5959
- There will need to be an issue associated with the initial part of the deprecation. A second issue needs to be created to finish the job. The first issue will be linked to second issue. The second issue needs to be a sub-task of an appropriate [deprecation META](https://tracker.moodle.org/issues/?jql=%28summary%20~%20%22meta%22%20or%20type%20%3D%20Epic%29%20AND%20summary%20~%20%22together%20deprecated%22%20order%20by%20created&runQuery=true&clear=true).
6060

@@ -229,8 +229,9 @@ Named parameter arguments are available from PHP 8.0 onwards.
229229

230230
## See also...
231231

232-
- [String deprecation](../../projects/api/string-deprecation.md)
232+
- [String deprecation](../../../projects/api/string-deprecation.md)
233233
- [External functions deprecation](/docs/apis/subsystems/external/writing-a-service#deprecation)
234234
- [Capabilities deprecation](/docs/apis/subsystems/access#deprecating-a-capability)
235-
- [Process](../process.md)
236-
- [Release process](../process/release/index.md)
235+
- [SCSS deprecation](./scss-deprecation.md)
236+
- [Process](../../process.md)
237+
- [Release process](../../process/release/index.md)
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: SCSS Deprecation
3+
tags:
4+
- Processes
5+
- Core development
6+
- Deprecation
7+
- SCSS
8+
---
9+
import { Since } from '@site/src/components';
10+
11+
<Since versions={["4.4"]} issueNumber={"MDL-78334"} />
12+
13+
Since Moodle 4.4, it's possible to deprecate SCSS styles and classes. This allows us to safely remove SCSS and will help us keep the code cleaner and more organized.
14+
15+
The most common scenarios where this functionality can be used is when specific SCSS code is not being used anywhere, when the name of a class is changed or a class should not be used in the future.
16+
17+
:::info When should SCSS be removed?
18+
19+
There are situations where deprecation does not make sense. For example when a whole functionality is being removed, or a very specific SCSS class is no longer used by the code. If it is very unlikely that the SCSS class is used by any other code, it can simply be removed without the full deprecation process.
20+
21+
:::
22+
23+
## How it works
24+
25+
A new SCSS file called `deprecated.scss` has been added to the `theme/boost/scss/moodle` folder. All the deprecated SCSS code should be added to this file.
26+
27+
In this file a new mixin called `deprecated-styles` has been also added. This mixin will add a red backgound to the deprecated styles and also a `:before` pseudo-element with the text "Deprecated style in use". It is important to note that `deprecated-styles` mixin will only affect sites with `themedesignermode` setting enabled or behat test running sites.
28+
29+
:::tip
30+
31+
If all the styles depending on the same parent are deprecated, is strongly recommended to deprecate the parent selector.
32+
33+
:::
34+
35+
## How to deprecate SCSS code
36+
37+
To deprecate SCSS code, follow these steps:
38+
39+
1. Remove the SCSS code that is no longer in use from the original file.
40+
2. Add the removed SCSS code to the `deprecated.scss` file under the comment for the current version `// Deprecated since Moodle X.Y.`
41+
3. Add the `deprecated-styles` mixin to the removed SCSS code.
42+
4. Add a comment to the removed SCSS code explaining why it has been deprecated.
43+
44+
:::note
45+
46+
If there is no section for the current version in the `deprecated.scss` file, it should be added. See [Final deprecation](#final-deprecation).
47+
48+
:::
49+
50+
**Example 1: Helper class has been removed**
51+
52+
```scss title="theme/boost/scss/moodle/deprecated.scss"
53+
// The class ".foo" is deprecated. Use ".bar" instead.
54+
.foo {
55+
@include deprecated-styles();
56+
57+
color: $pink;
58+
@include border-right-radius(0);
59+
border: $border-width solid $border-color;
60+
table {
61+
margin: 1rem;
62+
}
63+
table > tbody {
64+
padding: .5rem;
65+
}
66+
}
67+
```
68+
69+
**Example 2: SCSS code is no longer in use**
70+
71+
```scss title="theme/boost/scss/moodle/deprecated.scss"
72+
// The following styles are deprecated because they are no longer in use.
73+
// Deprecating the parent selector that contains all the deprecated styles.
74+
.path-course-view li.activity .foo {
75+
@include deprecated-styles();
76+
}
77+
.path-course-view li.activity .foo > a {
78+
text-decoration: none;
79+
color: $secondary;
80+
}
81+
.path-course-view li.activity .foo > a:hover {
82+
color: $primary;
83+
}
84+
```
85+
86+
## Final deprecation
87+
88+
When adding SCSS code to the `deprecated.scss` file, it is important to add it under the comment with the version when the code was deprecated. If that comment still doesn't exist, it should be added:
89+
90+
```scss title="theme/boost/scss/moodle/deprecated.scss"
91+
//
92+
// Deprecated since Moodle X.Y.
93+
//
94+
```
95+
96+
And alongside with that, a new issue should be created in the tracker to remove the deprecated SCSS code with the title `Remove strings deprecated in X.Y` and in the epic `X.[Y+4]` deprecations.
97+
98+
After 4 major versions, the deprecated SCSS code will be removed from the `deprecated.scss` file.
99+
100+
## Check deprecated styles in Behat tests
101+
102+
Is is possible to check if deprecated styles are being used while running Behat tests. To do so, add the `--scss-deprecations` flag to the Behat init command.
103+
104+
```bash
105+
php admin/tool/behat/cli/init.php --scss-deprecations
106+
```
107+
108+
Then, when running Behat tests, the following message will be displayed:
109+
110+
```bash
111+
Run optional tests:
112+
[...]
113+
- SCSS deprecations: Yes
114+
```
115+
116+
If deprecated styles are being used, the test will fail with the following message:
117+
118+
```bash
119+
Deprecated style in use (Exception)
120+
```

general/development/process.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ Decisions will be posted on the issue and that issue will be closed, allowing an
319319

320320
- [Detailed workflow](./process/_files/workflow.jpg)
321321
- [Release process](./process/release)
322-
- [Deprecation](./policies/deprecation.md)
322+
- [Deprecation](./policies/deprecation/index.md)
323323
- [Integration dashboard](http://tracker.moodle.org/secure/Dashboard.jspa?selectPageId=11350)
324324
Walks-though of the process for contributors:
325325
- By Dan Poltawski, Integrator: http://www.slideshare.net/poltawski/how-to-guarantee-your-change-is-integrated-to-moodle-core, https://www.youtube.com/watch?v=836WtnM2YpM

general/development/process/peer-review/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ To allow the community of Moodle developers to work together, conventions should
4545
- Variables are named correctly (all lower case, no camel-case, no underscores).
4646
- Functions are named correctly (all lower case, no camel-case, underscores allowed).
4747
- PHP DocBlocks have been updated and adhere to coding style guide.
48-
- Where functions are being removed, the [deprecation policy](../../policies/deprecation.md) is followed.
48+
- Where functions are being removed, the [deprecation policy](../../policies/deprecation/index.md) is followed.
4949
- The code doesn't use deprecated functions.
5050
- $_GET, $_POST, $_REQUEST, $_COOKIE, and $_SESSION are never used.
5151

@@ -182,7 +182,7 @@ Ensure that:
182182

183183
- The PHPdoc comments on all classes, methods and fields are useful. (Comments that just repeat the function name are not helpful! Add value.)
184184
- Where an API has been changed significantly, the relevant upgrade.txt file has been updated with information.
185-
- Where something has been deprecated, that the comments don't just say "do NOT use this any more!!!" but actually follow the [deprecation policy](../../policies/deprecation.md).
185+
- Where something has been deprecated, that the comments don't just say "do NOT use this any more!!!" but actually follow the [deprecation policy](../../policies/deprecation/index.md).
186186
- Appropriate [labels](../../tracker/labels.md) have been added when there has been a function change, particularly
187187
- docs_required (any functional change, usually paired with `ui_change`),
188188
- dev_docs_required (any change to APIs, usually paired with `api_change`),

general/development/process/release/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,4 @@ Usually on Monday
190190

191191
## See also
192192

193-
- [Deprecation process](../../policies/deprecation.md)
193+
- [Deprecation process](../../policies/deprecation/index.md)

0 commit comments

Comments
 (0)