... |
... |
@@ -14,7 +14,7 @@ if no issue already exists. |
14
|
14
|
|
15
|
15
|
For policies on how to submit an issue and how to use our project labels,
|
16
|
16
|
we recommend that you read the `policies guide
|
17
|
|
-<https://gitlab.com/BuildStream/nosoftware/alignment/blob/master/BuildStream_policies.md>`_
|
|
17
|
+<https://gitlab.com/BuildStream/nosoftware/alignment/blob/master/BuildStream_policies.md>`_.
|
18
|
18
|
|
19
|
19
|
|
20
|
20
|
.. _contributing_fixing_bugs:
|
... |
... |
@@ -192,6 +192,21 @@ code readability by being overly restrictive on line length for instance. |
192
|
192
|
The pep8 linter will run automatically when :ref:`running the test suite <contributing_testing>`.
|
193
|
193
|
|
194
|
194
|
|
|
195
|
+Line lengths
|
|
196
|
+''''''''''''
|
|
197
|
+Regarding laxness on the line length in our linter settings, it should be clarified
|
|
198
|
+that the line length limit is a hard limit which causes the linter to bail out
|
|
199
|
+and reject commits which break the high limit - not an invitation to write exceedingly
|
|
200
|
+long lines of code, comments, or API documenting docstrings.
|
|
201
|
+
|
|
202
|
+Code, comments and docstrings should strive to remain written for approximately 80
|
|
203
|
+or 90 character lines, where exceptions can be made when code would be less readable
|
|
204
|
+when exceeding 80 or 90 characters (often this happens in conditional statements
|
|
205
|
+when raising an exception, for example). Or, when comments contain a long link that
|
|
206
|
+causes the given line to to exceed 80 or 90 characters, we don't want this to cause
|
|
207
|
+the linter to refuse the commit.
|
|
208
|
+
|
|
209
|
+
|
195
|
210
|
.. _contributing_documenting_symbols:
|
196
|
211
|
|
197
|
212
|
Documenting symbols
|
... |
... |
@@ -389,7 +404,7 @@ on a Python class in BuildStream:: |
389
|
404
|
# Implementation of the "frobbish" abstract method
|
390
|
405
|
# defined by the parent Bar class.
|
391
|
406
|
#
|
392
|
|
- return True
|
|
407
|
+ return True
|
393
|
408
|
|
394
|
409
|
################################################
|
395
|
410
|
# Public Methods #
|
... |
... |
@@ -430,7 +445,7 @@ on a Python class in BuildStream:: |
430
|
445
|
# Returns:
|
431
|
446
|
# (int): The count of this foo
|
432
|
447
|
#
|
433
|
|
- def set_count(self, count):
|
|
448
|
+ def get_count(self, count):
|
434
|
449
|
|
435
|
450
|
return self._count
|
436
|
451
|
|
... |
... |
@@ -444,7 +459,7 @@ on a Python class in BuildStream:: |
444
|
459
|
# Even though these are private implementation
|
445
|
460
|
# details, they still MUST have API documenting
|
446
|
461
|
# comments on them.
|
447
|
|
-
|
|
462
|
+
|
448
|
463
|
# _do_frobbing()
|
449
|
464
|
#
|
450
|
465
|
# Does the actual frobbing
|
... |
... |
@@ -479,10 +494,10 @@ reference on how the PEP-8 defines public and non-public. |
479
|
494
|
|
480
|
495
|
A private symbol must be denoted by a leading underscore.
|
481
|
496
|
|
482
|
|
-* When a class can have subclasses (for example, the ``Sandbox`` or ``Platform``
|
|
497
|
+* When a class can have subclasses, then private symbols should be denoted
|
|
498
|
+ by two leading underscores. For example, the ``Sandbox`` or ``Platform``
|
483
|
499
|
classes which have various implementations, or the ``Element`` and ``Source``
|
484
|
|
- classes which plugins derive from), then private symbols should be denoted
|
485
|
|
- by two leading underscores.
|
|
500
|
+ classes which plugins derive from.
|
486
|
501
|
|
487
|
502
|
The double leading underscore naming convention invokes Python's name
|
488
|
503
|
mangling algorithm which helps prevent namespace collisions in the case
|
... |
... |
@@ -521,7 +536,7 @@ In order to disambiguate between: |
521
|
536
|
|
522
|
537
|
* Symbols which are publicly accessible details of the ``Element`` class, can
|
523
|
538
|
be accessed by BuildStream internals, but must remain hidden from the
|
524
|
|
- *"Public API Surface"*
|
|
539
|
+ *"Public API Surface"*.
|
525
|
540
|
|
526
|
541
|
* Symbols which are private to the ``Element`` class, and cannot be accessed
|
527
|
542
|
from outside of the ``Element`` class at all.
|
... |
... |
@@ -571,7 +586,7 @@ is found at ``_artifactcache/artifactcache.py``. |
571
|
586
|
|
572
|
587
|
Imports
|
573
|
588
|
~~~~~~~
|
574
|
|
-Module imports inside BuildStream are done with relative ``.`` notation
|
|
589
|
+Module imports inside BuildStream are done with relative ``.`` notation:
|
575
|
590
|
|
576
|
591
|
**Good**::
|
577
|
592
|
|
... |
... |
@@ -613,12 +628,12 @@ which exposes an instance variable is the only one in control of the value of th |
613
|
628
|
variable.
|
614
|
629
|
|
615
|
630
|
* If an instance variable is public and must be modified; then it must be
|
616
|
|
- modified using a :ref:`mutator <contributing_accessor_mutator>`
|
|
631
|
+ modified using a :ref:`mutator <contributing_accessor_mutator>`.
|
617
|
632
|
|
618
|
633
|
* Ideally for better encapsulation, all object state is declared as
|
619
|
634
|
:ref:`private instance variables <contributing_public_and_private>` and can
|
620
|
635
|
only be accessed by external classes via public :ref:`accessors and mutators
|
621
|
|
- <contributing_accessor_mutator>`
|
|
636
|
+ <contributing_accessor_mutator>`.
|
622
|
637
|
|
623
|
638
|
.. note::
|
624
|
639
|
|
... |
... |
@@ -705,10 +720,10 @@ In BuildStream, we use the term *"Abstract Method"*, to refer to |
705
|
720
|
a method which **can** be overridden by a subclass, whereas it
|
706
|
721
|
is **illegal** to override any other method.
|
707
|
722
|
|
708
|
|
-* Abstract methods are allowed to have default implementations
|
|
723
|
+* Abstract methods are allowed to have default implementations.
|
709
|
724
|
|
710
|
725
|
* Subclasses are not allowed to redefine the calling signature
|
711
|
|
- of an abstract method, or redefine the API contract in any way
|
|
726
|
+ of an abstract method, or redefine the API contract in any way.
|
712
|
727
|
|
713
|
728
|
* Subclasses are not allowed to override any other methods.
|
714
|
729
|
|
... |
... |
@@ -783,7 +798,7 @@ BstError parameters |
783
|
798
|
When raising ``BstError`` class exceptions, there are some common properties
|
784
|
799
|
which can be useful to know about:
|
785
|
800
|
|
786
|
|
-* **message:** The brief human readable error, will be formatted on one line in the frontend
|
|
801
|
+* **message:** The brief human readable error, will be formatted on one line in the frontend.
|
787
|
802
|
|
788
|
803
|
* **detail:** An optional detailed human readable message to accompany the **message** summary
|
789
|
804
|
of the error. This is often used to recommend the user some course of action, or to provide
|
... |
... |
@@ -959,9 +974,9 @@ symbols to a minimum, this is important for both |
959
|
974
|
|
960
|
975
|
When anyone visits a file, there are two levels of comprehension:
|
961
|
976
|
|
962
|
|
-* What do I need to know in order to *use* this object
|
|
977
|
+* What do I need to know in order to *use* this object.
|
963
|
978
|
|
964
|
|
-* What do I need to know in order to *modify* this object
|
|
979
|
+* What do I need to know in order to *modify* this object.
|
965
|
980
|
|
966
|
981
|
For the former, we want the reader to understand with as little effort
|
967
|
982
|
as possible, what the public API contract is for a given object and consequently,
|
... |
... |
@@ -986,9 +1001,9 @@ well documented and minimal. |
986
|
1001
|
|
987
|
1002
|
When adding new API to a given object for a new purpose, consider whether
|
988
|
1003
|
the new API is in any way redundant with other API (should this value now
|
989
|
|
-go into the constructor, since we use it more than once ? could this
|
|
1004
|
+go into the constructor, since we use it more than once? could this
|
990
|
1005
|
value be passed along with another function, and the other function renamed,
|
991
|
|
-to better suit the new purposes of this module/object ?) and repurpose
|
|
1006
|
+to better suit the new purposes of this module/object?) and repurpose
|
992
|
1007
|
the outward facing API of an object as a whole every time.
|
993
|
1008
|
|
994
|
1009
|
|
... |
... |
@@ -1168,7 +1183,7 @@ The BuildStream documentation style is as follows: |
1168
|
1183
|
* Cross references should be of the form ``:role:`target```.
|
1169
|
1184
|
|
1170
|
1185
|
* Explicit anchors can be declared as ``.. _anchor_name:`` on a line by itself.
|
1171
|
|
-
|
|
1186
|
+
|
1172
|
1187
|
* To cross reference arbitrary locations with, for example, the anchor ``anchor_name``,
|
1173
|
1188
|
always provide some explicit text in the link instead of deriving the text from
|
1174
|
1189
|
the target, e.g.: ``:ref:`Link text <anchor_name>```.
|
... |
... |
@@ -1251,23 +1266,23 @@ Documentation Examples |
1251
|
1266
|
The examples section of the documentation contains a series of standalone
|
1252
|
1267
|
examples, here are the criteria for an example addition.
|
1253
|
1268
|
|
1254
|
|
-* The example has a ``${name}``
|
|
1269
|
+* The example has a ``${name}``.
|
1255
|
1270
|
|
1256
|
|
-* The example has a project users can copy and use
|
|
1271
|
+* The example has a project users can copy and use.
|
1257
|
1272
|
|
1258
|
|
- * This project is added in the directory ``doc/examples/${name}``
|
|
1273
|
+ * This project is added in the directory ``doc/examples/${name}``.
|
1259
|
1274
|
|
1260
|
|
-* The example has a documentation component
|
|
1275
|
+* The example has a documentation component.
|
1261
|
1276
|
|
1262
|
1277
|
* This is added at ``doc/source/examples/${name}.rst``
|
1263
|
1278
|
* A reference to ``examples/${name}`` is added to the toctree in ``doc/source/examples.rst``
|
1264
|
1279
|
* This documentation discusses the project elements declared in the project and may
|
1265
|
|
- provide some BuildStream command examples
|
1266
|
|
- * This documentation links out to the reference manual at every opportunity
|
|
1280
|
+ provide some BuildStream command examples.
|
|
1281
|
+ * This documentation links out to the reference manual at every opportunity.
|
1267
|
1282
|
|
1268
|
|
-* The example has a CI test component
|
|
1283
|
+* The example has a CI test component.
|
1269
|
1284
|
|
1270
|
|
- * This is an integration test added at ``tests/examples/${name}``
|
|
1285
|
+ * This is an integration test added at ``tests/examples/${name}``.
|
1271
|
1286
|
* This test runs BuildStream in the ways described in the example
|
1272
|
1287
|
and assert that we get the results which we advertize to users in
|
1273
|
1288
|
the said examples.
|
... |
... |
@@ -1294,17 +1309,17 @@ The ``.run`` file format is just another YAML dictionary which consists of a |
1294
|
1309
|
|
1295
|
1310
|
Each *command* is a dictionary, the members of which are listed here:
|
1296
|
1311
|
|
1297
|
|
-* ``directory``: The input file relative project directory
|
|
1312
|
+* ``directory``: The input file relative project directory.
|
1298
|
1313
|
|
1299
|
|
-* ``output``: The input file relative output html file to generate (optional)
|
|
1314
|
+* ``output``: The input file relative output html file to generate (optional).
|
1300
|
1315
|
|
1301
|
1316
|
* ``fake-output``: Don't really run the command, just pretend to and pretend
|
1302
|
1317
|
this was the output, an empty string will enable this too.
|
1303
|
1318
|
|
1304
|
|
-* ``command``: The command to run, without the leading ``bst``
|
|
1319
|
+* ``command``: The command to run, without the leading ``bst``.
|
1305
|
1320
|
|
1306
|
1321
|
* ``shell``: Specifying ``True`` indicates that ``command`` should be run as
|
1307
|
|
- a shell command from the project directory, instead of a bst command (optional)
|
|
1322
|
+ a shell command from the project directory, instead of a bst command (optional).
|
1308
|
1323
|
|
1309
|
1324
|
When adding a new ``.run`` file, one should normally also commit the new
|
1310
|
1325
|
resulting generated ``.html`` file(s) into the ``doc/source/sessions-stored/``
|
... |
... |
@@ -1402,7 +1417,7 @@ a subdirectory beside your test in which to store data. |
1402
|
1417
|
When creating a test that needs data, use the datafiles extension
|
1403
|
1418
|
to decorate your test case (again, examples exist in the existing
|
1404
|
1419
|
tests for this), documentation on the datafiles extension can
|
1405
|
|
-be found here: https://pypi.python.org/pypi/pytest-datafiles
|
|
1420
|
+be found here: https://pypi.python.org/pypi/pytest-datafiles.
|
1406
|
1421
|
|
1407
|
1422
|
Tests that run a sandbox should be decorated with::
|
1408
|
1423
|
|