Skip to content

Commit

Permalink
Update docs for CI (#636)
Browse files Browse the repository at this point in the history
* update CI info in docs

* Fix markdown lint issues

* Update docs/CONTRIBUTING.md

Co-authored-by: Ryan Hartlage <[email protected]>

* Use consistent URL syntax in CONTRIBUTING.md

* Update line breaks in ABOUT.md

* Lint style guide

Fix some typos and grammar, unify URL syntax, fix some line breaks

* Lint INSTALLATION.md

Fix line breaks and bad URLS, unify URL syntax

* Lint LEARNING.md

* Update URLs in RESOURCES.md

Improve grammar also

* Lint Tests.md

Improve grammar also

* Lint VERSIONS.md

* Resolve naming of workflows/scripts

* Apply suggestions from code review

Co-authored-by: Ryan Hartlage <[email protected]>
  • Loading branch information
wolf99 and ryanplusplus authored Mar 10, 2021
1 parent 5943ba6 commit 5146d55
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 122 deletions.
8 changes: 5 additions & 3 deletions docs/ABOUT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# About

C is a general purpose language, used for a wide range of applications, from embedded computers to high-performance computing clusters.
C is a general purpose language, used for a wide range of applications, from embedded computers to high-performance computing clusters.

C is commonly found in low level applications as it's a good alternative to harder-to-read assembly languages. It can be compiled to assembly to keep the same level of performance, while increasing readability, and providing a small level of safety with static types!
C is commonly found in low level applications as it's a good alternative to harder-to-read assembly languages.
It can be compiled to assembly to keep the same level of performance, while increasing readability, and providing a small level of safety with static types!

C was created by Dennis Ritchie at Bell Labs, and used to re-implement the Unix operating system. Now, it's one of the most used programming languages, with many compilers supporting providing support for most available hardware and platforms - there's plenty of resources and support available to help you get started!
C was created by Dennis Ritchie at Bell Labs, and used to re-implement the Unix operating system.
Now, it's one of the most used programming languages, with many compilers supporting providing support for most available hardware and platforms - there's plenty of resources and support available to help you get started!
158 changes: 105 additions & 53 deletions docs/CONTRIBUTING.md

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions docs/C_STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

This guide describes the style intended for use with the C track exercise example and test files.

The rules within this guide are in addition to, or to call out, those in the [Linux kernel coding style guide](https://www.kernel.org/doc/html/latest/process/coding-style.html).
The rules within this guide are in addition to, or to call out, those in the [Linux kernel coding style guide][].

## C Standard

Code should conform to the C99 standard, more formally known as ISO/IEC 9899:1999. POSIX, or otherwise non-standard library functions, types or other references that are external to the implementation should not be used.
Code should conform to the C99 standard, more formally known as ISO/IEC 9899:1999.
POSIX, or otherwise non-standard library functions, types or other references that are external to the implementation should not be used.

## Names

Expand Down Expand Up @@ -54,22 +55,24 @@ While aware that POSIX reserves the `_t` suffix, the track does not currently ut
## Parameters
Function parameters should be named in both the declaration and definition of all functions. This applies to both `.c` and `.h` files.
Function parameters should be named in both the declaration and definition of all functions.
This applies to both `.c` and `.h` files.
The names used should match in all instances.
That is to say that while the following function prototype is valid C, the style is incorrect because the parameter is unnamed: `void foo(int);`.
The correct prototype, providing that all other declarations and the definition also use the parameter name `bar`, would be `void foo(int bar);`.
Where it is simpler or more appropriate to do so, parameters that require passing arguments by value rather than by pointer are preferred. Note especially that this includes `struct` type parameters.
Where it is simpler or more appropriate to do so, parameters that require passing arguments by value rather than by pointer are preferred.
Note especially that this includes `struct` type parameters.
In the case that a student is not expected to change the values of a pointer-type parameter within their implementation, that parameter should be `const` qualified.
## Indentation and Format
The repository uses the `indent` tool, as outlined in the [contributing guide](https://github.com/exercism/c/blob/master/docs/CONTRIBUTING.md).
The repository uses the `indent` tool, as outlined in the [contributing guide][].
The options described for use with indent there are `-linux -i3 -nut`. The `-linux` option is a shortcut that is equivelent to a secific fixed group of options. The combined equivalent options are `-nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i3 -nut -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -il1`.
The options described for use with indent there are `-linux -i3 -nut`. The `-linux` option is a shortcut that is equivalent to a specific fixed group of options. The combined equivalent options are `-nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i3 -nut -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -il1`.
What these options do is indicated by the [GNU `indent` manual](https://www.gnu.org/software/indent/manual/indent.html#SEC4), but is also described here for easy reference if editing files manually.
What these options do is indicated by the [GNU `indent` manual][indent-manual], but is also described here for easy reference if editing files manually.
- `nbad` - Do _not_ force blank lines after every block of declarations
- `bap` - Force a black line after every function body
Expand Down Expand Up @@ -107,7 +110,7 @@ What these options do is indicated by the [GNU `indent` manual](https://www.gnu.
## Test file layout
Each exercise's test file follows a particular layout.
the test file of each exercise follows a particular layout.
The layout is intended to both help contributors to identify parts of the file, and to help learners to understand how the tests work.
Like most C source files, a test file begins with includes.
Expand Down Expand Up @@ -138,6 +141,7 @@ Next are the test functions themselves.
The names of these functions use a `test_` prefix.
Excepting the first, each test function should have `TEST_IGNORE();` as its first statement.
The first occurrence of this should be followed by the line comment `// delete this line to run test`.
For example:
```c
Expand Down Expand Up @@ -177,3 +181,7 @@ int main(void)
return 0;
}
```
[Linux kernel coding style guide]: https://www.kernel.org/doc/html/latest/process/coding-style.html
[contributing guide]: ./CONTRIBUTING.md
[indent-manual]: https://www.gnu.org/software/indent/manual/indent.html#SEC4
29 changes: 13 additions & 16 deletions docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,26 @@ on your system:
* A modern C compiler
* The Make build tool

Apple's Xcode IDE combines the compiler and
the native build system into a single IDE (integrated development
environment). Linux environments typically expose the compiler and native
build system as separate command-line tools.

Apple's Xcode IDE combines the compiler and the native build system into a single IDE (integrated development environment).
Linux environments typically expose the compiler and native build system as separate command-line tools.

## Linux

Linux users will need gcc or clang for the compiler, and `make` will be needed
for the native build. Make is pre-installed on most unix systems, but is most
likely available via your package manager. On Debian and Ubuntu based
distributions everything you need can be installed with `sudo apt-get install build-essential`
if not present.

Linux users will need gcc or clang for the compiler, and `make` will be needed for the native build.
Make is pre-installed on most unix systems, but is most likely available via your package manager.
On Debian and Ubuntu based distributions everything you need can be installed with `sudo apt-get install build-essential` if not present.

## MacOS

MacOS users can install gcc or clang with [Homebrew](http://brew.sh/) via
`brew install gcc` or `brew install llvm`.

MacOS users can install gcc or clang with [Homebrew][]] via `brew install gcc` or `brew install llvm`.

## Windows

Windows 10 users are recommended to use [WSL Bash](https://msdn.microsoft.com/en-us/commandline/wsl/about), and proceed with the instruction for linux above.
Windows 10 users are recommended to use the [Windows Subsystem for Linux][], and proceed with the instruction for linux above.

If you are using an earlier version of Windows or WSL Bash is not available to you, you could use [MSYS][] or or [mingw-w64][].

If you are using an earlier version of Windows or WSL Bash is not available to you, you could use [MSYS/MinGW](http://www.mingw.org/) (32-bit only) or [mingw6-w64](http://mingw-w64.org/doku.php) (32 & 64-bit).
[Homebrew]: https://brew.sh
[Windows Subsystem for Linux]: https://msdn.microsoft.com/en-us/commandline/wsl/about
[MSYS]: https://www.msys2.org/
[mingw-w64]: http://mingw-w64.org/doku.php
54 changes: 26 additions & 28 deletions docs/LEARNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,33 @@

## Learning C From Ground Zero

In general, exercism assumes you already know the syntax and mechanisms
of a language in a particular track. However, knowing the syntax of a
language is merely the first step in gaining expertise in a language.
Exercism allows you to practice solving problems and share discussion
with other programmers who have solved the same problem. It is from
the shared discussion that we gain expertise and insight into becoming
better programmers.

If you are brand new to the C language, you should spend time learning
the basics of the language first. Here are a few resources that can
help you get started:

* [Learn C](http://www.learn-c.org/)
* [CS50x](https://www.edx.org/course/introduction-computer-science-harvardx-cs50x)

[CodeChef](https://www.codechef.com/ide) is a simple web form
interface to a C compiler that will let you try out small programs.
Sometimes this can be an easier way to perform a quick experiment than
building something locally in an integrated development environment.
In general, Exercism assumes you already know the syntax and mechanisms of a language in a particular track.
However, knowing the syntax of a language is merely the first step in gaining expertise in a language.
Exercism allows you to practice solving problems and share discussion with other programmers who have solved the same problem.
It is from the shared discussion that we gain expertise and insight into becoming better programmers.

If you are brand new to the C language, you should spend time learning the basics of the language first.
Here are a few resources that can help you get started:

* [Learn C][]
* [CS50x][]

[CodeChef][] is a simple web form interface to a C compiler that will let you try out small programs.
Sometimes this can be an easier way to perform a quick experiment than building something locally in an integrated development environment.

## Test-Driven Development in C

Exercism assumes that you are familiar with the concept of test-driven
development. Each exercise comes with a series of tests that are already
written for you. You progress through the exercise one test at a time,
writing an implementation incrementally to satisfy the tests.
Exercism assumes that you are familiar with the concept of test-driven development.
Each exercise comes with a series of tests that are already written for you.
You progress through the exercise one test at a time, writing an implementation incrementally to satisfy the tests.

If you are new to test-driven development, it is strongly recommended that you first work through a [quick overview of some test frameworks for C][test-frameworks] or read the book [Test-Driven Development for Embedded C][tdd] by James Grenning.
These resources cover [Unity][] and [CppUTest][]; this track uses Unity.

If you are new to test-driven development, it is strongly recommended
that you first work through a [quick overview of some test frameworks for C](http://www.drdobbs.com/testing/unit-testing-in-c-tools-and-conventions/240156344)
or read the book [Test-Driven Development for Embedded C](https://pragprog.com/book/jgade/test-driven-development-for-embedded-c)
by James Grenning. These resources cover [Unity](http://www.throwtheswitch.org/unity/)
and [CppUTest](http://cpputest.github.io/); this track uses Unity.
[Learn C]: https://www.learn-c.org/
[CCS50x]: https://www.edx.org/course/cs50s-introduction-to-computer-science
[CodeChef]: https://www.codechef.com/ide
[test-frameworks]: https://www.drdobbs.com/testing/unit-testing-in-c-tools-and-conventions/240156344
[tdd]: https://pragprog.com/book/jgade/test-driven-development-for-embedded-c
[Unity]: https://www.throwtheswitch.org/unity/
[CppUTest]: https://cpputest.github.io/
5 changes: 3 additions & 2 deletions docs/RESOURCES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Resources

- [C++ Reference](http://en.cppreference.com/w/): An online reference for C and C++ programming languages. You have a doubt what a method does? cppreference.com has you covered.
- [`C` tag on StackOverflow](http://stackoverflow.com/questions/tagged/c)
- [C++ Reference](https://en.cppreference.com/w/c): An online reference for C and C++ programming languages.
If you are not sure what a stdlib function does, this site has you covered.
- [`C` tag on StackOverflow](https://stackoverflow.com/questions/tagged/c)
23 changes: 12 additions & 11 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Each test file is meant to link against your implementation to provide a console
Running the test executable prints messages for each failing test and reports a non-zero exit status when tests fail.

To work through an exercise:

* Create the initial build with Make
* For each unit test:
* Remove the `TEST_IGNORE()` line.
Expand All @@ -24,39 +25,39 @@ For instance, the exercise `bob` expects an implementation in `src/bob.h` and `s
For exercises with dashes in their name, the source files are assumed to use underscores, so `word-count` expects `src/word_count.h` and `src/word_count.c`.
You may decide that your implementation is sufficiently simple that it can live entirely in the header, in which case you can omit the `c` file.

**Create your initial implementation files before running Make.**
**Create your initial implementation files before running Make.**
If you do not have files `src/bob.h` and `src/bob.c` when running Make for exercise `bob`, then Make will generate an error about files not being found.
**These files can be empty, but they must exist.**

### Build your code

The simplest way to build your code is by using `make` at the command line (CLI).
On Linux the CLI is available in bash or similar, on MacOS use Terminal.
On Linux the CLI is available in bash or similar, on MacOS use Terminal.
On Windows 10, the Windows Subsystem for Linux (WSL) Bash is available.

To do this, assuming we're in the exercise folder:
To do this, assuming the current directory is the exercise folder:

```bash
$ make
make
```

This will compile your code, and run the tests.

The `makefile` comes also with a build that checks some common mistakes regarding memory leaks and out of bound access to arrays. To run these checks, simply run:
```
$ make memcheck
The `makefile` comes also with a build that checks some common mistakes regarding memory leaks and out of bound access to arrays. To run these checks, use the following at the command line:

```bash
make memcheck
```
from the command line.

### Clean up

To clean up after a build, you can tell `make` to delete all of the build output, including the executable:

```bash
$ make clean
make clean
```

#### MacOS Build Alternative
On MacOS you can also use Xcode.
To build the code select _Build_ from the toolbar.

On MacOS you can also use Xcode.
To build the code select _Build_ from the toolbar.
2 changes: 1 addition & 1 deletion docs/VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Versions

- Unity = v2.5.2 (version now specified in `unity.h`)
* Unity = v2.5.2 (version now specified in `unity.h`)

0 comments on commit 5146d55

Please sign in to comment.