Skip to content

Commit 4c1fd1c

Browse files
authored
Merge pull request #8 from nhsengland/sh_update_documentation
Sh update documentation
2 parents d4aae3f + 006dcc7 commit 4c1fd1c

5 files changed

Lines changed: 82 additions & 41 deletions

File tree

.github/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Github config files
2+
This directory is used to define templates for pull requests and issues, alongside defining the CI/CD in the "workflows" directory.

CONTRIBUTING.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,41 @@
11
# How to contribute
22

3-
First off, thank you for taking the time to contribute! If you have a function that you would like to see in codon, we have a few standards and guidelines that we would like you to follow before we consider your merge request. Failure to follow the contribution guide will result in your merge request being challenged or rejected.
3+
First off, thank you for taking the time to contribute! If you have a function that you would like to see in the National Reusable Code Library, we have a few standards and guidelines that we would like you to follow before we consider your merge request. Failure to follow the contribution guide will result in your merge request being challenged or rejected.
44

5-
We are looking for functions and/or classes which are useful for workflows in DIS specifically. Please do not submit the following...
6-
* End-to-end scripts cannot be implemented into the package. If you find something reusable within your end-to-end script, then please feel free to extract it and submit it to Codon with tests attached.
7-
* Multiple functions that are unrelated. For example, "This function takes an integer number and rounds it to the nearest whole number". Please do not include multiple functions unless they're methods of a class or are related to the same file (i.e. two methods of suppression)
5+
We are looking for reusable functions and/or classes which are useful across multiple workflows in NHS data processing and analytics. Please do not submit the following...
6+
* End-to-end scripts that cannot be implemented into the package. If you find something reusable within your end-to-end script, then please feel free to extract it and submit it with its unit tests attached.
87
* Duplicated functionality. For example, if your function is already done by another well known package.
98
* Irrelevant functionality. If the function you submit is unrelated to DIS, it will mostly likely be challenged or rejected.
109

11-
## Basic idea
10+
When making a submission, it is helpful if this is kept small, and that the content is all related / follows a theme / are different methods of a class. It will make review and acceptance more straightforward.
1211

13-
1. [Fork](https://help.github.com/en/articles/fork-a-repo) codonPython on GitHub.
12+
## Eligibilty
13+
Anyone is free to suggest contributions this repository, access it, and utilise its contents. However, as a number of steps for the approval process take place within NHS England, if you're external it might be wise to email the repository owners to discuss your submission so that they can bring it through the governance and approval process within NHS England. Otherwise you might end up waiting until someone notices a new pull request and considers it.
1414

15-
2. Write your documented function and tests (:heart_eyes:) on a new branch, coding in line with our **coding conventions**.
15+
The process for submitting new code is:
1616

17-
3. Submit a [pull request](https://help.github.com/en/articles/creating-a-pull-request) **to the dev branch** of codonPython with a clear description of what you have done.
17+
1. Identify the reusable components within your code and refactor them to be standalone functions / classes (e.g. no integrated or dependent on the work they were originally a part of)
18+
2. [Fork](https://help.github.com/en/articles/fork-a-repo) this repo on GitHub.
19+
4. Write your documented function and tests (:heart_eyes:) on a new branch, coding in line with our **coding standards**.
20+
5. Submit a [pull request](https://help.github.com/en/articles/creating-a-pull-request) **main branch** of the National Reusable Code Library with a clear description of what you have done, fully completing all sections of the `pull_request_template.md` (the empty template should appear automatically in the pull request).
21+
6. The maintainers of the repository will review the code, and, if it meets the basic standards set out here, take if for consideration to the Reusable Code Advisory Group within NHS England.
22+
7. If rejected, feedback will be provided, and once this has been actioned it can taken back to the Advisory Group
23+
8. IF accepted, the pull request will be merged into the main branch.
24+
9. At regular interverals, the code will be packaged up and released - the commit will be tagged with a semantic version, following the usual approach of trivial, minor and major (breaking) changes. These versioned packages will be published to PyPi and potentially other package repositories.
1825

1926
We suggest you make sure all of your commits are atomic (one feature per commit). Please make sure that non-obvious lines of code are commented, and variable names are as clear as possible. Please do not send us undocumented code as we will not accept it. Including tests to your pull request will bring tears of joy to our eyes, and will also probably result in a faster merge.
2027

21-
## Coding conventions
28+
## Coding standards
2229

23-
We use the industry standard [PEP 8](https://www.python.org/dev/peps/pep-0008/) styling guide within the `codonPython` package. **Therefore, it’s imperative that you use the coding standards found within PEP 8 when creating or modifying any code within the `codonPython` package**. Autoformatters for PEP8, for instance [black](https://black.readthedocs.io/en/stable/), can easily ensure compliance. The reason we use PEP 8 coding standards is to make sure there is a layer of consistency across our codebase. This reduces the number of decisions that you need to make when styling your code, and also makes code easier to read when switching between functions etc.
30+
In short:
31+
- Follow PEP-8, and use Black to enforce this on your code
32+
- Have unit tests for all your functions / methods
33+
- Write [Numpy-style](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard) docstrings for functions, including descriptions, inputs, outputs, and example usage
34+
- Methods used in the code should have been approved by the appropriate body, e.g. the Data Quality Steering Group for DQ rules. For external submissions, this might require a longer review process in which these are brought to those bodies.
2435

25-
While you are creating code, we recommend that you understand the style guide standards for the following topics:
36+
We use the industry standard [PEP 8](https://www.python.org/dev/peps/pep-0008/) styling guide. **Therefore, it’s imperative that you use the coding standards found within PEP 8 when creating or modifying any code within the repository**. Autoformatters for PEP8, for instance [black](https://black.readthedocs.io/en/stable/), can easily ensure compliance. The reason we use PEP 8 coding standards is to make sure there is a layer of consistency across our codebase. This reduces the number of decisions that you need to make when styling your code, and also makes code easier to read when switching between functions etc.
2637

38+
The following articles can be useful when writing code to the standard:
2739
* [Code layout](https://www.python.org/dev/peps/pep-0008/#code-lay-out) – Indentation, tabs or spaces, maximum line length, blank lines, source file encoding, imports & module level Dunder name
2840
* [String quotes](https://www.python.org/dev/peps/pep-0008/#string-quotes)
2941
* [Whitespace in expressions and statements](https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements) – Pet Peeves, alternative recommendations
@@ -32,21 +44,11 @@ While you are creating code, we recommend that you understand the style guide st
3244
* [Naming conventions](https://www.python.org/dev/peps/pep-0008/#naming-conventions) – Naming styles, naming conventions, names to avoid, ASCII compatibility, package and module names, class names, type variable names, exception names, global variable names, function and variable names, function and method arguments, method names and instance variables, constants & designing for inheritance
3345
* [Programming recommendations](https://www.python.org/dev/peps/pep-0008/#programming-recommendations) – Function annotations & variable annotations
3446

35-
We also use docstrings and we try to follow [`numpy`'s docstring standards](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard).
3647

37-
Start reading our code to get a feel for it but most importantly, remember that this is open source software - consider the people who will read your code, and make it look nice for them.
48+
## Community
3849

39-
* We use [PEP8](https://www.python.org/dev/peps/pep-0008/). Autoformatters for PEP8, for instance [black](https://black.readthedocs.io/en/stable/), can easily ensure compliance.
40-
* We use docstrings and we try to (loosely) follow [`numpy`'s docstring standards](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard).
41-
* This is open source software. Consider the people who will read your code, and make it look nice for them.
42-
43-
## Tests
44-
45-
We do ask that you include some basic tests with your contributions. While the logic of your contribution is important, some basic unit tests to verify functionality and data types for the inputs are requested for a baseline level of assurance and 'elegant failing'.
50+
The discussions space on this github repo is the perfect place to discuss the code and reach out to those working on it.
4651

4752
## Code of Conduct
4853

49-
As a contributer you can help us keep the Codon community open and inclusive. Please read and follow our [Code of Conduct](https://github.com/codonlibrary/code-of-conduct/tree/master). By contributing to it, you agree to comply with it.
50-
51-
:clinking_glasses: Thank you!
52-
Team codon
54+
As a contributer you can help us keep the this community open and inclusive. Please read and follow our [Code of Conduct](https://github.com/codonlibrary/code-of-conduct/tree/master). By contributing to it, you agree to comply with it.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Copyright 2019 NHS Digital DIS Team
1+
Copyright 2025 NHS England Data Architecture Team
2+
3+
# BSD 3-Clause Licence
24

35
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
46

@@ -8,4 +10,4 @@ Redistribution and use in source and binary forms, with or without modification,
810

911
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1012

11-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,62 @@ By making code reusable, and making it easy to reuse, this work aims to:
2424

2525
**Be more cost effective**: Reusable 'generalised' code will increase efficiency in creating higher level processes.
2626

27-
2827
## Installation
29-
The package can be directly installed by typing in your terminal:
30-
```r
31-
# TBC
28+
The package can be directly installed as a python package from PyPi by in your terminal:
29+
```terminal
30+
pip install nhs_reusable_code_library
3231
```
3332
Other platform specific instructions to follow.
3433

34+
## How to use the National Reusabel Code Library package
35+
When using Python, given that you've installed the package as described above, you can simply [import](https://docs.python.org/3/tutorial/modules.html#packages) it as normal:
36+
37+
```Python
38+
from nhs_reusable_code_library.standard_data_validations.nhsNumberValidation import mod11_check
39+
40+
nhs_number = '1111111111'
41+
42+
nhs_number_valid = mod11_check(nhs_number)
43+
```
44+
45+
## Code Manfiest
46+
(Made using "[project-tree-generator](https://project-tree-generator.netlify.app/generate-tree)")
47+
48+
```
49+
Reusable-Code-Library/
50+
├── .github/ # Directory for github specific templates and CI/CD (github actions)
51+
│ ├── ISSUE_TEMPLATE/ # templates for when people raise issues
52+
│ ├── pull_request_template.md # template used when a pull request is raised
53+
│ └── workflows/ # Github Actions (CI/CD) pipelines go here
54+
│ └── ci.yml # This is the Continuous Integration pipeline which runs the unit tests and tests the package builds
55+
└── src/
56+
│ └── nhs_reusable_code_library/ # the main package directory which will have a number of libraries
57+
│ ├── standard_data_validations/ # the place for data quality rules code
58+
│ │ ├── nhsNumberValidation/ # NHS number validation related code
59+
│ │ ├── polars/ # Polars implementations of data quality rules code
60+
│ │ └── pyspark/ # PySpark implementations of data quality ruls code
61+
│ └── tests/ # the unit tests for the functions within the package
62+
├── .gitignore # tells the repo which files to ignore, e.g. temporary, hidden and background files, and outputs.
63+
├── CONTRIBUTING.md # Describes how to contribute to the repository
64+
├── LICENSE # Describes the License the code can be used under.
65+
├── pyproject.toml # Used when building the package
66+
└── README.md # Describes what the package is for and how to use it.
67+
```
68+
69+
## Governance
70+
New reusable code is discussed and signed off in the Reusable Code Assurance Group within NHS England. This group also sets the standards this code is made to.
71+
New code must have appropriate unit tests and all unit tests must pass before it can be merged into the main branch. These tests can be found in the `src/.../tests` folders.
72+
3573
## Contributing
36-
All new contributions to the `National Reusable Code Library` are welcome; please follow the Coding Conventions in the guidance document for contribution guidance.
74+
All new contributions to the `National Reusable Code Library` are welcome; please follow the guidance document for contributions.
3775

3876
Any improvements to documentation, bug fixes or general code enhancements are also welcomed. If a bug is found on the master branch, please use the GitHub guidance on raising an [issue.](https://help.github.com/en/github/managing-your-work-on-github/creating-an-issue)
3977

4078
## New to GitHub?
41-
GitHub is a hosting site that allows for development and version control of software using Git. It allows users to edit and develop parts of code independently before submitting back to the master code, whilst using version control to track changes. Introductory videos to GitHub for beginners can be found [here.](https://github.com/codonlibrary/codonPython/wiki/2a.-GitHub-for-Beginners)
42-
43-
Quick links to beginner guidance can also be found below:
44-
45-
* [**Cloning a repository to your local machine using GitBash**](https://github.com/codonlibrary/codonPython/wiki/1.-Installing-codonPython)
46-
* [**Checking out a branch using GitBash**](https://github.com/codonlibrary/codonPython/wiki/2b.-Checkout-a-branch-using-GitBash)
47-
* [**Removing a Commit from a repository using GitBash**](https://github.com/codonlibrary/codonPython/wiki/3.-Removing-a-Commit-From-a-GitHub-Repository)
79+
GitHub is a hosting site that allows for development and version control of software using Git. It allows users to edit and develop parts of code independently before submitting back to the master code, whilst using version control to track changes. Introductory guidance can be found here: [https://nhsdigital.github.io/rap-community-of-practice/training_resources/git/introduction-to-git/]
4880

49-
All other `codon` "How-to Articles" can be found [here.](https://github.com/codonlibrary/codonPython/wiki/2.-Git-Guidance)
81+
## Acknowledgments
82+
Thanks in particular to the amazing work of both the [NHS Digital RAP Squad](https://nhsdigital.github.io/rap-community-of-practice), and the [NHS Codon Project](https://github.com/codonlibrary/codonPython) who greatly inspired this work and set the foundations for it years ago.
5083

51-
Suggestions regarding additional guidance or How-to articles are welcome.
84+
## Contact
85+
NHS England Data Architecture Team

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Documentation files
22

3-
The files that Sphinx builds the documentation from are located here. ReStructuredText `.rst` files are text files similar to markdown which allow formatting and interactivity with Sphinx. As with the functions in codon, improvements to the documentation files here are welcolmed.
3+
## ToDo
4+
This currently contains the old files from the Codon project - it needs updating to automatically generate code documentation, e.g. via Sphinx.

0 commit comments

Comments
 (0)