Skip to content

Commit 382e16e

Browse files
committed
feat(docs): add markdown linter for exercises README.md files
1 parent 362c1b0 commit 382e16e

File tree

9 files changed

+36
-11
lines changed

9 files changed

+36
-11
lines changed

.github/workflows/lint.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: DavidAnson/markdownlint-cli2-action@v9
17+
with:
18+
globs: "exercises/**/*.md"

.markdownlint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# MD013/line-length Line length, Expected: 80
2+
MD013: false

exercises/conversions/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The simplest form of type conversion is a type cast expression. It is denoted wi
66

77
Rust also offers traits that facilitate type conversions upon implementation. These traits can be found under the [`convert`](https://doc.rust-lang.org/std/convert/index.html) module.
88
The traits are the following:
9+
910
- `From` and `Into` covered in [`from_into`](from_into.rs)
1011
- `TryFrom` and `TryInto` covered in [`try_from_into`](try_from_into.rs)
1112
- `AsRef` and `AsMut` covered in [`as_ref_mut`](as_ref_mut.rs)
@@ -17,5 +18,6 @@ These should be the main ways ***within the standard library*** to convert data
1718
## Further information
1819

1920
These are not directly covered in the book, but the standard library has a great documentation for it.
21+
2022
- [conversions](https://doc.rust-lang.org/std/convert/index.html)
21-
- [`FromStr` trait](https://doc.rust-lang.org/std/str/trait.FromStr.html)
23+
- [`FromStr` trait](https://doc.rust-lang.org/std/str/trait.FromStr.html)

exercises/hashmaps/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Hashmaps
2+
23
A *hash map* allows you to associate a value with a particular key.
3-
You may also know this by the names [*unordered map* in C++](https://en.cppreference.com/w/cpp/container/unordered_map),
4+
You may also know this by the names [*unordered map* in C++](https://en.cppreference.com/w/cpp/container/unordered_map),
45
[*dictionary* in Python](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) or an *associative array* in other languages.
56

67
This is the other data structure that we've been talking about before, when

exercises/lifetimes/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
Lifetimes tell the compiler how to check whether references live long
44
enough to be valid in any given situation. For example lifetimes say
55
"make sure parameter 'a' lives as long as parameter 'b' so that the return
6-
value is valid".
6+
value is valid".
77

8-
They are only necessary on borrows, i.e. references,
8+
They are only necessary on borrows, i.e. references,
99
since copied parameters or moves are owned in their scope and cannot
1010
be referenced outside. Lifetimes mean that calling code of e.g. functions
11-
can be checked to make sure their arguments are valid. Lifetimes are
11+
can be checked to make sure their arguments are valid. Lifetimes are
1212
restrictive of their callers.
1313

14-
If you'd like to learn more about lifetime annotations, the
15-
[lifetimekata](https://tfpk.github.io/lifetimekata/) project
16-
has a similar style of exercises to Rustlings, but is all about
14+
If you'd like to learn more about lifetime annotations, the
15+
[lifetimekata](https://tfpk.github.io/lifetimekata/) project
16+
has a similar style of exercises to Rustlings, but is all about
1717
learning to write lifetime annotations.
1818

1919
## Further information

exercises/macros/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rust's macro system is very powerful, but also kind of difficult to wrap your
44
head around. We're not going to teach you how to write your own fully-featured
55
macros. Instead, we'll show you how to use and create them.
66

7-
If you'd like to learn more about writing your own macros, the
7+
If you'd like to learn more about writing your own macros, the
88
[macrokata](https://github.com/tfpk/macrokata) project has a similar style
99
of exercises to Rustlings, but is all about learning to write Macros.
1010

exercises/options/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Options
22

3-
Type Option represents an optional value: every Option is either Some and contains a value, or None, and does not.
3+
Type Option represents an optional value: every Option is either Some and contains a value, or None, and does not.
44
Option types are very common in Rust code, as they have a number of uses:
5+
56
- Initial values
67
- Return values for functions that are not defined over their entire input range (partial functions)
78
- Return value for otherwise reporting simple errors, where None is returned on error

exercises/smart_pointers/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Smart Pointers
2+
23
In Rust, smart pointers are variables that contain an address in memory and reference some other data, but they also have additional metadata and capabilities.
34
Smart pointers in Rust often own the data they point to, while references only borrow data.
45

exercises/traits/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Data types can implement traits. To do so, the methods making up the trait are d
77
In this way, traits are somewhat similar to Java interfaces and C++ abstract classes.
88

99
Some additional common Rust traits include:
10+
1011
- `Clone` (the `clone` method)
1112
- `Display` (which allows formatted display via `{}`)
1213
- `Debug` (which allows formatted display via `{:?}`)
1314

1415
Because traits indicate shared behavior between data types, they are useful when writing generics.
1516

16-
1717
## Further information
1818

1919
- [Traits](https://doc.rust-lang.org/book/ch10-02-traits.html)

0 commit comments

Comments
 (0)