@@ -28,10 +28,35 @@ Then, go into `parse_transform_serialize()` and so on.
28
28
29
29
To understand the most fundamental operation in styler, the manipulation of the
30
30
columns related to spacing and line break information, pick a rule from
31
- ` R/rules-*.R ` , e.g. ` R/rules-spacing ` , add a breakpoint to a rule and style a
31
+ ` R/rules-*.R ` , e.g. ` R/rules-spacing ` , add a break point to a rule and style a
32
32
string where you think this rule will be active. Then, see what happens and how
33
33
this rule is applied on each level of nesting.
34
34
35
+ ## Static code analysis
36
+
37
+ There are multiple packages that can be used to analyze a code base:
38
+
39
+ * [ gitsum] ( https://github.com/lorenzwalthert/gitsum ) : Parses and summarises git
40
+ repository history.
41
+ * [ parsesum] ( https://github.com/lorenzwalthert/parsesum ) : Analyses source code
42
+ through parsing.
43
+
44
+ Check out the links above to see how the tools listed could help you
45
+ understanding styler.
46
+
47
+ ## Project setup
48
+
49
+ * The package is developed with the devtools suite, which includes roxgen2 for
50
+ documentation, testthat for unit testing, pkgdown for html documentation.
51
+ * Continuous integration is done with the tic (tasks integrating continuously)
52
+ package.
53
+ * A key development principle of styler is to separate infrastructure from
54
+ style guide. Hence, whenever possible, transformer functions should be
55
+ adapted, not the infrastructure should be changed for a specific style guide.
56
+ * styler was created in 2017 by Kirill Müller, then turned from a
57
+ proof-of-concept into a ready-for-production tool as part of GSOC 2017 with
58
+ Kirill Müller and Yihui Xie as mentors and Lorenz Walthert as student.
59
+
35
60
36
61
## File Structure
37
62
@@ -66,3 +91,44 @@ The source code is organized as follows:
66
91
| vertical.R | S3 class for pretty printing of styled code. |
67
92
| visit.R | Functions that apply functions to each level of nesting, either inside out or outside in. |
68
93
| zzz.R | backport imports. |
94
+
95
+
96
+ ## High-level conventions
97
+
98
+ * The project follows a highly functional approach. This means that
99
+ functionality should be capsuled into functions, even if they are only called
100
+ once. This makes abstraction from the code easier, reduces the number of lines
101
+ for each function declaration considerably and makes it easier for people not
102
+ familiar with the code base to dive into it.
103
+ * All internal functions (except if they are 100% self-explanatory) are to be
104
+ documented.
105
+ * New functionality (e.g. in terms of styling rules) needs to be unit tested. If
106
+ the new functionality changes how code is to be styled, the infrastructure
107
+ with ` test_collection() ` should be used.
108
+ * Cases that are not yet formatted correctly can be labelled with a ` FIXME ` .
109
+ * GitHub is the platform where communication about source code happens. We
110
+ refrain from adding extensive in-line code comments. One can use ` git blame `
111
+ to track when changes were introduced and find the corresponding pull request
112
+ and associated issues to understand the thought process that lead to a change
113
+ in the source code. This also implies that issues and / or pull request
114
+ contain verbose explanation of problems and solutions provided.
115
+
116
+ ## Low-level coventions
117
+
118
+ This project follows the [ tidyverse style guide] ( http://style.tidyverse.org ) .
119
+
120
+ ### Files
121
+ * File names only contain alphanumeric characters and dashes.
122
+ * Files are named according to topics / contexts, not according to functions
123
+ that live in these files.
124
+
125
+ ### Functions
126
+
127
+ * Function names should be verbs. No abbreviations should be used, we don't
128
+ care if function names are particularly long. For example, there is a
129
+ function with the name ` remove_line_break_before_round_closing_after_curly() ` .
130
+ * only very low-level functions or functions that don't fit in any other file
131
+ go to ` utils.R ` .
132
+
133
+
134
+
0 commit comments