Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

50 normalise book #220

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2a8685b
added oxford commas for consistency
beth-e-jones Oct 21, 2024
d83f87c
punctuation and typo changes
beth-e-jones Oct 21, 2024
e2015a2
minor punctuation edits on Principles
beth-e-jones Oct 23, 2024
fd20a7d
punctuation and grammatical edits
beth-e-jones Oct 23, 2024
a7730df
punctuation consistency in Readable Code
beth-e-jones Oct 23, 2024
27f0d8e
consistency edits for Structure chapter
beth-e-jones Oct 23, 2024
276f42d
minor edits on code documentation chapter
beth-e-jones Oct 24, 2024
680e77f
punctuation edits as far as Vignettes in project_docs
beth-e-jones Oct 24, 2024
8a56c84
edits for continuity in punctuation
beth-e-jones Oct 24, 2024
ebb8bf4
minor edits for punctuation and style consistency
beth-e-jones Oct 24, 2024
b61174b
consistency in formatting for data chapter
beth-e-jones Oct 24, 2024
8184c8e
removed duplicated paragrapjs
beth-e-jones Oct 24, 2024
3f3919d
consistency in style and punctuation for CI chapter
beth-e-jones Oct 24, 2024
4b1eb79
Merge branch 'main' of https://github.com/best-practice-and-impact/qa…
beth-e-jones Oct 29, 2024
6299459
reduced passive sentences in introduction
beth-e-jones Oct 29, 2024
3fdd502
removed several passive sentences in glossary
beth-e-jones Oct 29, 2024
4fb416d
removed passive sentences in managers guide
beth-e-jones Oct 29, 2024
7c9a4bb
removed passive sentences in Principles chapter
beth-e-jones Oct 30, 2024
00fd4a1
reduced passive sentences in Modular code chapter
beth-e-jones Oct 30, 2024
a152fcc
reduced passive sentences in Readable Code
beth-e-jones Oct 30, 2024
5495130
edited passive sentences in modular code section
beth-e-jones Oct 30, 2024
fddbd6d
reduced passive sentences in Project Structure chapter
beth-e-jones Oct 31, 2024
09fa804
reduced passive sentences in Documenting Code
beth-e-jones Oct 31, 2024
cd49e18
reduced passive sentences in project documentation section
beth-e-jones Oct 31, 2024
203cfba
reduced passive sentences in Documenting Projects section
beth-e-jones Oct 31, 2024
c831519
editing passive sentences in version control section
beth-e-jones Oct 31, 2024
1215d1e
editing passive sentences in version control (done to line 600)
beth-e-jones Oct 31, 2024
227b773
reduced passive sentences in version control
beth-e-jones Nov 4, 2024
442f339
reduced passive sentences in configuration section
beth-e-jones Nov 4, 2024
7df59bc
reduced passive sentences in data management section
beth-e-jones Nov 4, 2024
5e156ee
reduced passive sentences in peer review chapter
beth-e-jones Nov 4, 2024
c6985b3
edited passive voice and simplified some parts in automating qa chapter
ellie-o Nov 20, 2024
a1f04b2
Merging branch to pick up testing chapter edits so book can be normal…
ellie-o Jan 13, 2025
71ec243
Reduced passive voice in testing chapter. Some grammar edits and simp…
ellie-o Jan 15, 2025
4c055fe
converted some passive sentences to active in testing chapter
beth-e-jones Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set wd ("D:/repos/qa-of-code-guidance")
set wd (D:/repos/qa-of-code-guidance)
setwd ("D:/repos/qa-of-code-guidance")
46 changes: 22 additions & 24 deletions book/code_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ Comments are lines of text in source code files that typically aren't executed a
They are small notes or annotations written by those working on the code.
Often, they provide context or explain the reasoning behind implementation decisions.

Comments are essential to help those working on the code in the future to understand any non-obvious details
around how and why the code has been written in a particular way.
Comments are essential for explaining non-obvious details around around how and why the code has been written in a particular way to help those working on the code in the future.
As such, when it comes to providing relevant and perhaps higher-level documentation to the end consumer on the functionality of your code,
there are much more appropriate solutions such as [docstrings](docstrings).

Although extremely useful, comments should be used sparingly.
Excessive use of code comments often leads to redundancy and can, ironically, make your code harder to read.
It is easy for comments to not be updated as changes are made to the code.
Outdated, or irrelevant comments can confuse or mislead.
It is easy to fail to update comments as you change code. However, outdated, or irrelevant comments can confuse or mislead.

```{note}
**Remember**: the only point of 'truth' is the code that is executed - if the comments are out of date compared to the actual code, it may not be immediately apparent.
Expand Down Expand Up @@ -156,20 +154,20 @@ print("Run me!")
````

It is easy to forget which parts of code have been commented out and why they have been commented.
It introduces a human factor into the equation, which might not be accounted for if someone in the future is not aware of the commented-out code.
A human factor is then introduced into the equation, which might not be accounted for if someone in the future is not aware of the commented-out code.
This is likely to produce inconsistent runs of the same piece of code.
This code might quickly become out of sync with the rest of the changes in the codebase,
as developers may not consider updating code that is commented out if they assume it is obsolete.

You should instead use appropriate control flow (such as `if/else` statements) to determine when these sections should be run.
When changes are required between individual runs of your analysis, you should consider [defining these options in a dedicated configuration file](configuration.md).
You should consider [defining these options in a dedicated configuration file](configuration.md) when changes are required between individual runs of your analysis.

In summary, you should use comments sparingly but purposefully.
Make sure comments:

- explain **why** certain things are done, in order to provide context around the decisions that you have made
- do not echo what your code is already telling the reader
- are accurate and still relevant after code changes
- explain **why** certain things are done, in order to provide context around the decisions that you have made.
- do not echo what your code is already telling the reader.
- are accurate and still relevant after code changes.


(docstrings)=
Expand Down Expand Up @@ -279,9 +277,9 @@ You should use it to write function documentation as part of R packages.
If you are documenting functions that are not part of a package, you can use regular code comments.
However, documenting functions using roxygen syntax can be helpful if you are planning on packaging the code in future and gives a clear structure to your documentation.

You might find that writing function, class or package descriptions prior to writing their code helps you to focus on the task at hand.
You might find that writing function, class, or package descriptions prior to writing their code helps you to focus on the task at hand.
The documentation should be a specification of what the code is expected to do.
As documentation tends to be user-focussed, this approach helps you to keep the user's needs in mind when developing code and
As documentation tends to be user-focused, this approach helps you to keep the user's needs in mind when developing code and
provides a quick reference when more information on its capabilities are required.

Lastly, perhaps one of the key things to remember when writing docstrings is to **keep them up to date**.
Expand Down Expand Up @@ -323,11 +321,11 @@ In those cases, the structure is a lot looser and will depend on what the script
The docstrings should be brief and avoid repeating details found in function documentation or other code comments later in the script.
You may want to include:

- a title
- a brief description
- any important usage notes not covered elsewhere
- any copyright information if the script reproduces open source code from elsewhere
- academic citations, if applicable
- A title.
- A brief description.
- Any important usage notes not covered elsewhere.
- Any copyright information if the script reproduces open source code from elsewhere.
- Academic citations, if applicable.

````{tabs}

Expand Down Expand Up @@ -359,7 +357,8 @@ Duck census main analysis

Produces the duck census bulletin outputs for the annual publication.

Check the configuration file before running and run from the command line. Detailed setup and desk instructions can be found in README.md.
Check the configuration file before running and run from the command line.
Detailed setup and desk instructions can be found in README.md.

"""
```
Expand All @@ -369,7 +368,8 @@ Check the configuration file before running and run from the command line. Detai
#
# Produces the duck census bulletin outputs for the annual publication.
#
# Check the configuration file before running and run from the command line. Detailed setup and desk instructions can be found in README.md.
# Check the configuration file before running and run from the command line.
Detailed setup and desk instructions can be found in README.md.
```

````
Expand Down Expand Up @@ -402,13 +402,12 @@ Sphinx primarily uses the [`reStructuredText`](https://docutils.sourceforge.io/d
That said, for those more familiar with `markdown` and in teams/environments where learning a new markup language is not a top priority,
[`sphinx` can be extended to also support `markdown`](https://www.sphinx-doc.org/en/master/usage/markdown.html).

Sphinx supports code highlighting for multiple programming languages within a project,
however, other tools may be required to automatically collate documentation from code in languages other than Python. These are not addressed here.
Sphinx supports code highlighting for multiple programming languages within a project. However, you may require other tools to automatically collate documentation from code in languages other than Python. These are not addressed here.

Sphinx also supports theming, with a [myriad of themes](https://www.writethedocs.org/guide/tools/sphinx-themes/) available out of the box.
With a little bit of extra time you can even develop and adapt the existing themes into a custom theme suitable for your work.
You can even develop and adapt the existing themes into a custom theme suitable for your work with a little bit of extra time.

As well as theming support, `sphinx` allows users to develop extensions that extend its functionality.
`Sphinx` allows users to develop extensions that extend its functionality, as well as theming support,.
This GitHub repository provides a list of [useful ways to extend the functionality of `sphinx`](https://github.com/yoloseem/awesome-sphinxdoc) to suit your needs.

To illustrate how this can be extremely useful, we will introduce the [doctest extension](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html).
Expand All @@ -432,8 +431,7 @@ provide a good demonstration of how you would apply it in practice.

Once built, the HTML files containing your documentation can be opened in any browser.
Usually this means looking for an `index.html` file in the output directory and opening it with your browser.
This is sufficient for local usage, however, in order to improve the end-user experience and remove the need to browse the files looking for `index.html`,
it is wise to host this documentation somewhere where it will be publicly available.
This is sufficient for local usage. However,it is wise to host this documentation somewhere where it will be publicly available to improve the end-user experience and remove the need to browse the files looking for `index.html`.

Your version control platform might support hosting web pages already.
GitHub provides this hosting via [GitHub Pages](https://pages.github.com/) and is able to host not only documentation,
Expand Down
Loading
Loading