occlib/lib.rs
1/*!
2``occlib`` is The Open Cinema Collective's python library template. To build your own
3documentation, simply start using it. Below we will show some example documentation with
4the basic functions of this library template.
5
6Demo
7====
8
9```rust
10use occlib::cast_spell;
11
12assert_eq!(cast_spell(), "Avada Kedavra")
13```
14
15Occlib comes with a number of pre-built quality-of-life macros for developers so they
16can code more and manage less, most of which are accessed through ``make`` commands.
17
18In addition to your lib's package folder, occlib has two other main directories:
19
20 * ``./zdevelop`` - where maintenance scripts, and other information is stored
21
22In addition, the following files are used:
23
24 * ``./README.md`` - brief description and pointer to doc link for [Github](http://Githib.com)
25 * ``./setup.cfg`` - when possible, settings for all tools are stored here.
26 * ``./tarpaulin.toml`` - configuration for code coverage with [tarpaulin](https://github.com/xd009642/tarpaulin).
27 * ``./Makefile`` - contains make commands for the development features detailed in
28 this doc.
29 * ``./azure_pipelines.yml`` - build process definition for [Azure Pipelines](https://dev.azure.com/peake100/Open%20Cinema%20Collective/_build).
30
31Setting up your Library
32=======================
33
34Getting started is easy, just follow the below steps. Many of these steps include
35``Make`` scripts that help you get up and running quickly. To run the ``Make`` commands,
36ensure that the active directory of your terminal session is ``"occlib-py"``
37
381. Clone occlib-go from Github
39--------------------------------
40
41navigate to where you wish to keep your project in terminal: ::
42
43```shell
44cd /path/to/local_repository
45git clone https://github.com/opencinemac/occlib-rs.git
46```
47
48once the library is cloned, move into it as your active directory:
49
50```shell
51cd occlib-rs
52```
53
542. Pick a Name
55--------------
56
57When you have chosen a name for your new lib, update the Cargo.toml.
58
593. Pick a Description
60---------------------
61
62In the ``./Cargo.toml`` file, under the ``[metadata]`` header, change the ``description``
63field to a brief description of your project.
64
654. Initialize a new git repo
66----------------------------
67
68You should delete the existing ``.git`` folder for the repository, then initialize a
69clean repo by typing:
70
71```shell
72git init
73```
74
75In the future, you may wish to cherry-pick commits / updates to this template into
76your own libraries. A guide for how to do that can be found here:
77
78[Guide needs to be written]
79
805. Register your library
81------------------------
82
83Please reference the relevant documentation for registering your library in Github,
84Azure Pipelines, etc. Links to relevant guides can be found below:
85
86[Guides need to be written]
87
88Writing Your Library
89====================
90
911. Style
92--------
93
94The Open Cinema Collective's style guide is simple and straightforward:
95
96 1. [rustfmt](https://github.com/rust-lang/rustfmt) first
97 2. [clippy](https://github.com/rust-lang/rust-clippy) second
98 3. When 1 & 2 contradict: see 1
99
100This keeps things simple, but consistent.
101
1022. Lint
103-------
104
105To check the formatting of your library, type:
106
107```shell
108make lint
109```
110
111This will run the following tools to tell you where adjustments need to be made:
112
113 * [rustfmt](https://github.com/rust-lang/rustfmt)
114 * [clippy](https://github.com/rust-lang/rust-clippy)
115 * [Misspell](https://github.com/client9/misspell)
116
1173. Re-format
118------------
119
120Strict pep8 and Black adherence, while useful in many ways to the organization, can be
121annoying and distracting to individual engineers. To help with this, the occlib
122template comes with tools to re-format your code for you.
123
124To re-format your code, type:
125
126```shell
127make format
128```
129
130This will run the following tools:
131
132 * [rustfmt](https://github.com/rust-lang/rustfmt)
133
134With these tools, keeping your code properly formatted is minimally invasive, and as an
135organization will lead to a more consistent, maintainable codebase.
136
1374. Test
138-------
139
140To run your tests type:
141
142```shell
143make test
144```
145
1465. Document
147-----------
148
149occlib uses the built-in cargo tools to making documentation. To create docs for your library,
150type:
151
152```shell
153make doc
154```
155
156Deploying Your Library
157======================
158
1591. Make Commits:
160----------------
161Make your commits as you work. Your commits will be made to the ``dev`` branch, changes
162are pushed to master automatically once builds are passed.
163
1642. Version:
165-----------
166
167The major / minor version of the library are set in the ``setup.cfg`` file under
168``version:target``.
169
170Patch versions are generated automatically by the build system. So if ``version:target``
171is ``1.2`` and the last published build was ``1.2.4`` the next build created will
172become ``1.2.5``.
173
174When a new major / minor version bump is desired, simply change the ``version:target``
175value, ie ``1.3`` or ``2.0``.
176
1773. Push:
178--------
179
180When you are ready, push your code to github. This will set off a chain of events that
181will:
182
183 * automatically run formatting and unit tests
184 * if tests are passed, build and push your library to be available to other developers
185 * uploads a new version to [crates.io](http://crates.io)
186
1874. Build:
188---------
189
190occlib uses [Azure Pipelines](https://dev.azure.com/peake100/Open%20Cinema%20Collective/_build) to
191automatically run builds.
192
193For more information on azure builds, see the
194[azure build templates repo](https://github.com/opencinemac/azure-pipelines-templates).
195
196Other Quality of Life Development Functions
197===========================================
198
1991. Scratch Folder
200-----------------
201
202The folder ``zdevelop/scratch`` is included in .gitignore, so you can store scratch work
203to do quick tests in this directory without accidentally causing a commit conflict.
204!*/
205
206/// casts a spell
207pub fn cast_spell() -> &'static str {
208 "Avada Kedavra"
209}
210
211#[cfg(test)]
212mod tests {
213 use crate::cast_spell;
214
215 #[test]
216 fn test_spell() {
217 assert_eq!("Avada Kedavra", cast_spell())
218 }
219}