Skip to content

Commit 444edd4

Browse files
authored
Merge pull request DSpace#5938 from lgeggleston/code_style_and_conventions
Create an initial CODE_CONVENTIONS.md and CODE_STYLE.md (Frontend)
2 parents 3814a34 + 256d3da commit 444edd4

5 files changed

Lines changed: 114 additions & 19 deletions

File tree

.github/pull_request_template.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ However, reviewers may request that you complete any actions in this list if you
2121

2222
- [ ] My PR is **created against the `main` branch** of code (unless it is a backport or is fixing an issue specific to an older branch).
2323
- [ ] My PR is **small in size** (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
24+
- [ ] My PR **follows all coding best practices** based on the [Code Conventions Guide](../CODE_CONVENTIONS.md)
2425
- [ ] My PR **passes [ESLint](https://eslint.org/)** validation using `npm run lint`
2526
- [ ] My PR **doesn't introduce circular dependencies** (verified via `npm run check-circ-deps`)
2627
- [ ] My PR **includes [TypeDoc](https://typedoc.org/) comments** for _all new (or modified) public methods and classes_. It also includes TypeDoc for large or complex private methods.
2728
- [ ] My PR **passes all specs/tests and includes new/updated specs or tests** based on the [Code Testing Guide](https://wiki.lyrasis.org/display/DSPACE/Code+Testing+Guide).
28-
- [ ] My PR **aligns with [Accessibility guidelines](https://wiki.lyrasis.org/display/DSDOC9x/Accessibility)** if it makes changes to the user interface.
29+
- [ ] My PR **aligns with [Accessibility guidelines](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408944958/Accessibility)** if it makes changes to the user interface.
2930
- [ ] My PR **uses i18n (internationalization) keys** instead of hardcoded English text, to allow for translations.
3031
- [ ] My PR **includes details on how to test it**. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
3132
- [ ] If my PR includes new libraries/dependencies (in `package.json`), I've made sure their licenses align with the [DSpace BSD License](https://github.com/DSpace/DSpace/blob/main/LICENSE) based on the [Licensing of Contributions](https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines#CodeContributionGuidelines-LicensingofContributions) documentation.

CODE_CONVENTIONS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# DSpace Angular Code Conventions
2+
3+
DSpace has established coding conventions or best practices that all contributions must follow in order
4+
to be accepted.
5+
6+
These code conventions describe the best practices for design and implementation of DSpace code, helping ensure that all DSpace components have a consistent layout and follow the essential Web Content Accessibility Guidelines ([WCAG](https://www.w3.org/WAI/standards-guidelines/wcag/)).
7+
The best practices for formatting your code are defined in our separate [Code Style Guidelines](CODE_STYLE.md).
8+
9+
For additional guidelines, see the wiki documentation for [User Interface Design Principles & Accessibility](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408945765/User+Interface+Design+Principles+Accessibility).
10+
11+
1. [Enforcement of Guidelines](#enforcement-of-guidelines)
12+
2. [Angular Guidelines](#angular-guidelines)
13+
1. [Templates in Base Theme should only use default Bootstrap styling](#templates-in-base-theme-should-only-use-default-Bootstrap-styling)
14+
2. [Required Bootstrap Components must use `ng-bootstrap` library](#required-bootstrap-components-must-use-ng-bootstrap-library)
15+
3. [Document methods and classes using TypeDoc](#document-methods-and-classes-using-typedoc)
16+
4. [Align with DSpace's User Interface Design Guidelines](#align-with-dspaces-user-interface-design-guidelines)
17+
3. [Accessibility Guidelines](#accessibility-guidelines)
18+
1. [Align with WCAG (Web Content Accessibility Guidelines) AA criteria](#align-with-wcag-web-content-accessibility-guidelines-aa-criteria)
19+
2. [Align with DSpace's User Interface Accessibility Guidelines](#align-with-dspaces-user-interface-accessibility-guidelines)
20+
21+
22+
## Enforcement of Guidelines
23+
24+
Enforcement of these code conventions is handled in two ways:
25+
* Some guidelines are enforced strictly via static code tools such as ESLint. Where possible, we prefer to automate enforcement.
26+
* All guidelines are enforced during code review by the assigned reviewers.
27+
28+
## Angular Guidelines
29+
30+
### Templates in Base Theme should only use default Bootstrap styling
31+
32+
All templates in the Base Theme ([/src/app](/src/app) directories) should only use default Bootstrap styling. Documentation at: https://getbootstrap.com/docs/4.6/getting-started/introduction/
33+
* Exceptions may be made for accessibility purposes. For example, Bootstrap notes their [default color scheme does not always have sufficient color contrast](https://getbootstrap.com/docs/4.0/getting-started/accessibility/#color-contrast).
34+
35+
### Required Bootstrap Components must use `ng-bootstrap` library
36+
37+
When Bootstrap Components (accordion, dropdown, etc …) are required you MUST use the included `ng-bootstrap` library. Documentation at: https://ng-bootstrap.github.io/#/components/accordion/examples
38+
39+
### Document methods and classes using TypeDoc
40+
41+
Write [TypeDoc](https://typedoc.org/) comments for all new (or modified) public methods and classes, as well as for large or complex private methods.
42+
43+
### Align with DSpace's User Interface Design Guidelines
44+
45+
In order to ensure consistent layout and behavior on all pages, please refer to the [User Interface Design Guidelines](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408945765/User+Interface+Design+Principles+Accessibility#UserInterfaceDesignPrinciples%26Accessibility-UserInterfaceDesignGuidelines). This documentation provides more details regarding User Interface layout/design and the elements (or components) used by the DSpace User Interface.
46+
47+
## Accessibility Guidelines
48+
49+
### Align with WCAG (Web Content Accessibility Guidelines) AA criteria
50+
51+
The DSpace User Interface strives to align with [WCAG](https://www.w3.org/WAI/standards-guidelines/wcag/) AA criteria. Some AAA criteria may also be supported. For more information see [Accessibility documentation](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408944958/Accessibility).
52+
53+
The use of the Bootstrap framework can help in achieving some WCAG goals such as ‘Visual Presentation’ (AAA), 'Parsing' (A), ‘Orientation’ (AA), ‘Reflow’ (AA) and ‘Text Spacing’ (AA). See the Bootstrap chapter ["Accessibility"](https://getbootstrap.com/docs/4.0/getting-started/accessibility/) for an explanation of WCAG and where to find additional information.
54+
55+
### Align with DSpace's User Interface Accessibility Guidelines
56+
57+
Refer to the [User Interface Accessibility Guidelines](https://wiki.lyrasis.org/spaces/DSDOC10x/pages/408945765/User+Interface+Design+Principles+Accessibility#UserInterfaceDesignPrinciples%26Accessibility-UserInterfaceAccessibilityGuidelines) for more detailed recommendations regarding HTML structure, ARIA labelling and more.

CODE_STYLE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# DSpace Angular/Typescript Code Style Guidelines
2+
3+
DSpace has established code style / code formatting guidelines that all contributions must follow in order
4+
to be accepted.
5+
6+
These code style guidelines describe the best practices for formatting your code. The best practices for design and implementation of your code are defined in our separate [Code Conventions](CODE_CONVENTIONS.md).
7+
8+
* [Enforcement of Guidelines](#enforcement-of-guidelines)
9+
* [TypeScript Style Guide](#typescript-style-guide)
10+
* [Angular Style Guide](#angular-style-guide)
11+
* [IDE Support](#ide-support)
12+
13+
14+
## Enforcement of Guidelines
15+
16+
Enforcement is handled by [ESLint](https://eslint.org/) using the configuration file in the root source directory: [.eslintrc.json](.eslintrc.json).
17+
18+
If you would like to pre-check your Pull Request for any Code Style issues, you can do so by running:
19+
20+
```
21+
npm run lint
22+
```
23+
24+
Code contributions may only suppress these rules if pre-approved. Code may suppress these rules by using [ESLint configuration comments](https://eslint.org/docs/latest/use/configure/rules#use-configuration-comments-1), for example `/* eslint-disable [rule-name] */`.
25+
26+
The DSpace TypeScript Style Guide is enforced on all Pull Requests to the "main" branch in `dspace-angular`. Therefore, if a Pull Request to the "main" branch does not align with the Style Guide, it will fail the build process within our GitHub CI.
27+
28+
## TypeScript Style Guide
29+
30+
For the DSpace Angular UI (written in TypeScript), we use [ESLint](https://eslint.org/) to validate the style of all Typescript (*.ts) files.
31+
All style rules are defined in [.eslintrc.json](.eslintrc.json).
32+
33+
## Angular Style Guide
34+
35+
Follow the [official Angular style guide](https://angular.dev/style-guide). It contains guidelines for naming files, directory structure, etc.
36+
37+
## IDE Support
38+
39+
Most IDEs include an ESLint plugin which can automatically enforce the defined style rules in your Typescript code.

CONTRIBUTING.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,10 @@ DSpace is a community built and supported project. We do not have a centralized
1212
We accept [GitHub Pull Requests (PRs)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) at any time from anyone.
1313
Contributors to each release are recognized in our [Release Notes](https://wiki.lyrasis.org/display/DSDOC9x/Release+Notes).
1414

15-
Code Contribution Checklist
16-
- [ ] PRs _should_ be smaller in size (ideally less than 1,000 lines of code, not including comments & tests)
17-
- [ ] PRs **must** pass [ESLint](https://eslint.org/) validation using `yarn lint`
18-
- [ ] PRs **must** not introduce circular dependencies (verified via `yarn check-circ-deps`)
19-
- [ ] PRs **must** include [TypeDoc](https://typedoc.org/) comments for _all new (or modified) public methods and classes_. Large or complex private methods should also have TypeDoc.
20-
- [ ] PRs **must** pass all automated pecs/tests and includes new/updated specs or tests based on the [Code Testing Guide](https://wiki.lyrasis.org/display/DSPACE/Code+Testing+Guide).
21-
- [ ] User interface changes **must** align with [Accessibility guidelines](https://wiki.lyrasis.org/display/DSDOC9x/Accessibility)
22-
- [ ] PRs **must** use i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
23-
- [ ] Details on how to test the PR **must** be provided. Reviewers must be aware of any steps they need to take to successfully test your fix or feature.
24-
- [ ] If a PR includes new libraries/dependencies (in `package.json`), then their software licenses **must** align with the [DSpace BSD License](https://github.com/DSpace/dspace-angular/blob/main/LICENSE) based on the [Licensing of Contributions](https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines#CodeContributionGuidelines-LicensingofContributions) documentation.
25-
- [ ] Basic technical documentation _should_ be provided for any new features or configuration, either in the PR itself or in the DSpace Wiki documentation.
26-
- [ ] If a PR fixes an issue ticket, please [link them together](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).
15+
We provide a [Code Contribution Checklist in our Pull Request Template](https://github.com/DSpace/dspace-angular/blob/main/.github/pull_request_template.md#checklist) which includes guidance
16+
on things we will look for in your PR.
17+
18+
We also provide a [Code Style Guide](CODE_STYLE.md) (detailing how to format your code) and a [Code Conventions Guide](CODE_CONVENTIONS.md) (detailing established coding best practices).
2719

2820
Additional details on the code contribution process can be found in our [Code Contribution Guidelines](https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines)
2921

@@ -37,7 +29,7 @@ Once you have an account setup, contact @tdonohue (via [Slack](https://wiki.lyra
3729
## Help others on mailing lists or Slack
3830

3931
DSpace has our own [Slack](https://wiki.lyrasis.org/display/DSPACE/Slack) community and [Mailing Lists](https://wiki.lyrasis.org/display/DSPACE/Mailing+Lists) where discussions take place and questions are answered.
40-
Anyone is welcome to join and help others. We just ask you to follow our [Code of Conduct](https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx) (adopted via Lyrasis).
32+
Anyone is welcome to join and help others. We just ask you to follow our [Code of Conduct](https://lyrasis.org/code-of-conduct/) (adopted via Lyrasis).
4133

4234
## Join a working or interest group
4335

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Overview
1010

1111
DSpace open source software is a turnkey repository application used by more than
1212
2,000 organizations and institutions worldwide to provide durable access to digital resources.
13-
For more information, visit https://www.dspace.org/
13+
For more information, visit https://dspace.org/
1414

1515
DSpace consists of both a Java-based backend and an Angular-based frontend.
1616

@@ -24,13 +24,15 @@ Downloads
2424
* Backend (REST API): https://github.com/DSpace/DSpace/releases
2525
* Frontend (User Interface): https://github.com/DSpace/dspace-angular/releases
2626

27+
On our wiki, you may also find a [list of all past releases, including their current levels of support](https://wiki.lyrasis.org/spaces/DSPACE/pages/69010426/Releases).
28+
2729

2830
## Documentation / Installation
2931

3032
Documentation for each release may be viewed online or downloaded via our [Documentation Wiki](https://wiki.lyrasis.org/display/DSDOC/).
3133

3234
The latest DSpace Installation instructions are available at:
33-
https://wiki.lyrasis.org/display/DSDOC9x/Installing+DSpace
35+
https://wiki.lyrasis.org/display/DSDOC10x/Installing+DSpace
3436

3537
Quick start
3638
-----------
@@ -349,7 +351,7 @@ See our [DSpace Code Testing Guide](https://wiki.lyrasis.org/display/DSPACE/Code
349351
Documentation
350352
--------------
351353
352-
Official DSpace documentation is available in the DSpace wiki at https://wiki.lyrasis.org/display/DSDOC9x/
354+
Official DSpace documentation is available in the DSpace wiki at https://wiki.lyrasis.org/display/DSDOC10x/
353355
354356
Some UI specific configuration documentation is also found in the [`./docs`](docs) folder of this codebase.
355357
@@ -382,7 +384,11 @@ To get the most out of TypeScript, you'll need a TypeScript-aware editor. We've
382384
Contributing
383385
-------------
384386
385-
See [Contributing documentation](CONTRIBUTING.md)
387+
See our [Contributing guidelines](CONTRIBUTING.md) for general tips on contributing back to DSpace.
388+
389+
For developers, we also provide guidelines for:
390+
* [Code Style](CODE_STYLE.md) - our code formatting rules
391+
* [Code Conventions](CODE_CONVENTIONS.md) - our established coding best practices
386392
387393
File Structure
388394
--------------
@@ -564,7 +570,7 @@ DSpace uses GitHub to track issues:
564570
License
565571
-------
566572
DSpace source code is freely available under a standard [BSD 3-Clause license](https://opensource.org/licenses/BSD-3-Clause).
567-
The full license is available in the [LICENSE](LICENSE) file or online at https://www.dspace.org/license/
573+
The full license is available in the [LICENSE](LICENSE) file or online at https://dspace.org/license/
568574

569575
DSpace uses third-party libraries which may be distributed under different licenses. Those licenses are listed
570576
in the [LICENSES_THIRD_PARTY](LICENSES_THIRD_PARTY) file.

0 commit comments

Comments
 (0)