DSpace has established coding conventions or best practices that all contributions must follow in order to be accepted.
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). The best practices for formatting your code are defined in our separate Code Style Guidelines.
For additional guidelines, see the wiki documentation for User Interface Design Principles & Accessibility.
Enforcement of these code conventions is handled in two ways:
- Some guidelines are enforced strictly via static code tools such as ESLint. Where possible, we prefer to automate enforcement.
- All guidelines are enforced during code review by the assigned reviewers.
All templates in the Base Theme (/src/app directories) should only use default Bootstrap styling. Documentation at: https://getbootstrap.com/docs/4.6/getting-started/introduction/
- Exceptions may be made for accessibility purposes. For example, Bootstrap notes their default color scheme does not always have sufficient color contrast.
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
Write TypeDoc comments for all new (or modified) public methods and classes, as well as for large or complex private methods.
In order to ensure consistent layout and behavior on all pages, please refer to the User Interface Design Guidelines. This documentation provides more details regarding User Interface layout/design and the elements (or components) used by the DSpace User Interface.
The DSpace User Interface strives to align with WCAG AA criteria. Some AAA criteria may also be supported. For more information see Accessibility documentation.
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" for an explanation of WCAG and where to find additional information.
Refer to the User Interface Accessibility Guidelines for more detailed recommendations regarding HTML structure, ARIA labelling and more.