Skip to content

Commit 499e9a2

Browse files
committed
Massive overhaul of Spin standard library
1 parent 52c9d10 commit 499e9a2

File tree

117 files changed

+409
-488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+409
-488
lines changed

CONTRIBUTING.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Spin Standard Library Style Guide
2+
3+
Traditionally, Spin has been difficult for inexperienced developers to start with.
4+
This has to change for it to be taken seriously as an educational platform.
5+
6+
This guide has been written to aid in developing a consistent, accessible out-of-the-box
7+
experience of the Spin language.
8+
9+
## Submissions
10+
11+
New object submissions should include demos for readily available reference
12+
hardware. For example:
13+
14+
* Sample code that runs as-is on a Propeller HYDRA
15+
* Sample code and a circuit schematic for running the code on a Propeller Activity Board
16+
17+
## Organization
18+
19+
The Spin Standard Library is organized into the following folder structure.
20+
21+
.
22+
└── library
23+
├── demos
24+
├── examples
25+
└── templates
26+
27+
#### library/
28+
29+
The top-level of the library that will be included with PropellerIDE. All core object additions go here.
30+
Anything above this level is not distributed.
31+
32+
##### demos/
33+
34+
These files are organized hierarchically based on the object they demonstrate. For example, let's say we
35+
have the following module.
36+
37+
com.serial.fullduplex
38+
39+
You should be able to find sample code for it in the following location:
40+
41+
com/serial/FullDuplex.spin
42+
43+
Or if there are multiple examples:
44+
45+
com/serial/fullduplex/ThisDemo.spin
46+
com/serial/fullduplex/ThatDemo.spin
47+
48+
##### examples/
49+
50+
Not all sample code fits neatly into one object or another. For more complex demonstrations that may
51+
use many different objects, the `examples/` folder is used.
52+
53+
This is a good place for demonstrations that will run as-is on a given piece of hardware.
54+
55+
##### templates/
56+
57+
Files included in `templates/` will be available within PropellerIDE's "New From Template" feature. These are
58+
named how they will appear, with spaces replaced with underscores. Therefore, "Awesome Template v1.0"
59+
should be saved as:
60+
61+
Awesome_Template_v1.0.spin
62+
63+
## Style
64+
65+
Owing to Spin's similarity to Python, for topics not covered here, please refer
66+
to [PEP-8](https://www.python.org/dev/peps/pep-0008/) where appropriate.
67+
68+
In no particular order:
69+
70+
* Skip one line after declaring a block and before starting a new one; no more, no less.
71+
72+
Yes:
73+
74+
PUB Foo
75+
76+
Bar
77+
78+
PUB Biz
79+
80+
Boo
81+
82+
No:
83+
84+
PUB Foo
85+
Bar
86+
PUB Biz
87+
88+
89+
90+
Boo
91+
92+
* Use **4** spaces for indentation.
93+
94+
* Always *indent* inside of blocks. Existing Spin compilers do not require this
95+
but failing to do so produces hard-to-read code.
96+
97+
Yes:
98+
99+
PUB Foo
100+
101+
Bar
102+
Baz
103+
104+
No:
105+
106+
PUB Foo
107+
108+
Bar
109+
Baz
110+
111+
* Treat all files as case-sensitive. Spin does not require this but it is good practice
112+
anyway.
113+
114+
* Always capitalize the same way.
115+
116+
* Blocks and constants are upper-case (`PUB`, `CON`, ...).
117+
118+
* Variables, labels, and non-block keywords are lower-case (`offsetx`, `temp`, ...).
119+
120+
* Function names are CamelCase (`DoSomething`, `EnableFeature`, ...).
121+
122+
* Avoid extraneous spaces in code.
123+
124+
* Avoid excessive commenting; only comment individual lines of code when necessary.
125+
126+
* **Do not** add licensing stubs or header information. This information is automatically
127+
added to software releases from the repository itself.
128+
129+
* **Do** add documentation comments after function block declarations. These will be
130+
rendered into documentation in later PropellerIDE releases.
131+
132+
PUB ThisFunction(val, val2)
133+
'' This is an interesting function
134+
135+
HereIsTheCode
136+
MoreCode(val2)
137+
val += 2
138+
139+
* Do not use Parallax font-specific special characters or in-source schematic diagrams.
140+
This feature is not portable and will be removed from PropellerIDE in the future.
141+
PropellerIDE will eventually support markdown syntax in documentation, so it is
142+
recommended to draw pictures of any diagrams and add them to a folder called `images/`
143+
in the same folder as the object.
144+
145+
For an illustration in a core object:
146+
147+
com.serial.fullduplex.spin
148+
images/com/serial/fullduplex/img1.png
149+
150+
For a demo object:
151+
152+
com/serial/fullduplex/FullDuplex.spin
153+
com/serial/fullduplex/images/img1.png
154+
155+
## Questions?
156+
157+
Please submit any questions or feedback you have to the
158+
[issue tracker](https://github.com/parallaxinc/spin-standard-library/issues).

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Brett Weir
3+
Copyright (c) 2015 Parallax Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

License.spin

Lines changed: 0 additions & 65 deletions
This file was deleted.

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
The Spin Standard Library
2-
=========================
1+
# The Spin Standard Library
32

4-
This project contains a collection of Spin code to get your Propeller up and running and doing interesting things.
3+
The Spin Standard Library is designed to be a definitive starting point for Spin programming. It contains a
4+
curated collection of Spin objects that have been organized and formatted for consistency, with a
5+
wide array of functionality represented.
56

6-
This library is part of the [PropellerIDE project](https://github.com/parallaxinc/PropellerIDE).
7+
The project is a part of the [PropellerIDE project](https://github.com/parallaxinc/PropellerIDE).
8+
9+
## Contributing
10+
11+
Please read the [guidelines](CONTRIBUTING.md) before submitting a pull request.
12+
13+
## Testing
14+
15+
You can compile every file in the project with the following script.
16+
17+
./scripts/test.sh
18+
19+
## License
20+
21+
This project is licensed under the [MIT license](LICENSE).

SPI_Spin.spin

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)