en:devmon:guidelines:tidy
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:devmon:guidelines:tidy [2021/08/12 09:32] – [Current Best Practice for Tidy] Bruno Manzoni | en:devmon:guidelines:tidy [2021/08/22 14:35] (current) – [Tidy Document] adminw1k1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Tidy ====== | ====== Tidy ====== | ||
| - | To make it easier to keep code clean, | + | To make documents |
| - | Objective | + | ==== Tidy Code ==== |
| + | |||
| + | To keep the code clean, follow this guide (but dont worry if you dont!) | ||
| + | |||
| + | === Tools=== | ||
| *Tidy perl code, ... (perltidy) | *Tidy perl code, ... (perltidy) | ||
| *Follow best practice (perlcritic) | *Follow best practice (perlcritic) | ||
| *Automate it (tidyall) | *Automate it (tidyall) | ||
| - | Installation | + | === Installation |
| - | Cpan minus (cpanm) install latest package, but this can break be in conflict with OS package manager. Make a backup if you can first. | + | Cpan minus (cpanm) install |
| < | < | ||
| Line 16: | Line 20: | ||
| cpanm install Code:: | cpanm install Code:: | ||
| </ | </ | ||
| + | |||
| + | ==== Usage ==== | ||
| " | " | ||
| - | In the project folder, you will find a file called: **" | + | In the project folder, you will find a file called: **" |
| \\ | \\ | ||
| \\ | \\ | ||
| Line 28: | Line 34: | ||
| To make it work (perltidy will reformat files with an inplace reformatting, | To make it work (perltidy will reformat files with an inplace reformatting, | ||
| - | To simulate the result: | ||
| < | < | ||
| tidyall -a | tidyall -a | ||
| </ | </ | ||
| - | And files are bakuped ind the " | + | And files are bakuped ind the **" |
| - | ===== Current Best Practice | + | ==== Current Best Practice |
| (Can change at any time: submit your proposal, critics) | (Can change at any time: submit your proposal, critics) | ||
| \\ | \\ | ||
| Line 43: | Line 48: | ||
| * 4 chars | * 4 chars | ||
| * no tabs | * no tabs | ||
| - | * Line lenght | + | * Line lenght |
| * Cuddle else ( else stay on the same line as the parenthesis) | * Cuddle else ( else stay on the same line as the parenthesis) | ||
| - | ===== Best Practice for Critic | + | ==== Best Practice for Critic ==== |
| (Wip, Not Implemented, | (Wip, Not Implemented, | ||
| - | === Use modern default: | + | == Use modern default: == |
| * use strict; | * use strict; | ||
| * use warning; | * use warning; | ||
| * use utf8; | * use utf8; | ||
| + | |||
| + | ==== Tidy Document ==== | ||
| + | |||
| + | To keep clean the other documents that are not code, follow this guide (but dont worry if you dont!) | ||
| + | |||
| + | |||
| + | === Tools=== | ||
| + | |||
| + | * Autoformat | ||
| + | |||
| + | === Current Best Practice with autoformat === | ||
| + | * 78 char per line | ||
| + | * (stating at pos 0) | ||
| + | |||
| + | === Installation === | ||
| + | Cpan minus (cpanm) install the latest package, but this can break be in conflict with OS package manager. | ||
| + | < | ||
| + | cpanm install Text:: | ||
| + | </ | ||
| + | |||
| + | Create the following script: (I named it: autoformat.pl) | ||
| + | < | ||
| + | # | ||
| + | # Minimal use: read from STDIN, format to STDOUT... | ||
| + | use strict; | ||
| + | use Text:: | ||
| + | my $str = do { local $/; < | ||
| + | my $out = autoformat $str, {left=> | ||
| + | print $out; | ||
| + | </ | ||
| + | |||
| + | And now you can format any text or markdown (this will not rendered in a Markdown reader, but Markdown files becomes more readable when they are read " | ||
| + | |||
| + | Make your script exectutable | ||
| + | < | ||
| + | chmod +x autoformat.pl | ||
| + | </ | ||
| + | |||
| + | And test it! | ||
| + | |||
| + | < | ||
| + | autoformat.pl < unformated.txt > formated.txt | ||
| + | autoformat.pl < unformated.md > formated.md | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
en/devmon/guidelines/tidy.1628753572.txt.gz · Last modified: 2021/08/12 09:32 by Bruno Manzoni