Developing Siemens Element¶
Prerequisites¶
- Git to clone the repository
- Git LFS to fetch test assets
- NodeJS version as specified in the package.json
- pnpm v11 or higher — enable via corepack (
corepack enable) or install withnpm install -g pnpm
To run the documentation, you will also need:
- Python version as specified in the pyproject.toml
- UV to manage Python virtual environments
Installation¶
Setting up the development environment:
git clone git@github.com:siemens/element.git
cd element
git lfs install
pnpm install
Building¶
We use path mappings within the repository. For development builds, they typically point to the sources, so building submodules is not necessary.
IMPORTANT: Always build the translation layer. It is not consumed form the sources.
To build modules use the available pnpm scripts:
# Build all modules
pnpm run build:all
# Build a specific module. See package.json for available modules.
pnpm run <module-name>:build
# E.g. build the translation layer
pnpm run translate:build
Translatable component text¶
See the translation abstraction guide for declaring and rendering translatable text, extracting keys, and testing translation behavior.
Running the example application¶
As for other builds, the translation layer must be built before running the application. Then you can run the example application with the corresponding pnpm script:
# Run the example application
pnpm run start
Linting and formatting¶
We use ESLint and Stylelint for linting and Prettier for formatting. Use the following pnpm scripts to lint and format the code:
# Format all modules
pnpm run format
# Lint all modules
pnpm run lint:ng
# Lint styles
pnpm run lint:scss
Third-party agent skills¶
Third-party agent skills are managed through skills.sh. Use pnx skills to add or update them so their sources and hashes are recorded in skills-lock.json.
When adding a third-party skill, add its path under .agents/skills/ to .prettierignore. Third-party skill sources must not be reformatted by this repository's Prettier configuration.
API Goldens¶
We guard our APIs against unintentional changes using API goldens based on API Extractor. Whenever the public API is changed, the corresponding golden must be updated.
protected members are considered internal and are excluded from the public API report.
Library builds set compilerOptions.incremental to false in tsconfig.lib.json. Restoring ng-packagr's cached TypeScript build information can change declaration ordering without source changes, causing spurious API golden differences on repeated builds. Angular's disk cache remains enabled, including for unit tests and the dev server. Browser test builds use tsconfig.spec.json, independently of the library compiler settings.
# Build and updates the API goldens. This is the main command needed for local development.
pnpm run api-goldens:build-accept
# Update the API goldens without building. !Important: APIs are generated based on the build output.
pnpm run api-goldens:accept
# Check the API goldens without updating them. !Important: this requires a build first.
pnpm run api-goldens:test
Unit Tests¶
Run the unit tests using the corresponding pnpm script:
pnpm run <module-name>:test
Previewing release notes¶
To preview the release notes that semantic-release would generate from the currently checked-out branch, run:
node tools/semantic-release/preview.js
The script detects the current branch and prints the prospective release notes to standard output. It runs semantic-release in dry-run mode without prepare, publish, Git, or GitHub plugins, so it does not modify files, create tags, or publish a release.
E2E Tests¶
Our E2E tests are built with Playwright. To ensure reliable screenshots, those tests must always be run in a container. The local test script uses Podman by default.
To run the E2E tests, use the following commands:
# On linux the host parameter can be omitted
pnpm run start --allowed-hosts true --host 0.0.0.0
# Build all dashboards artifacts and start the server
pnpm run dashboards-demo:build-and-run-all
# Build all ESM dashboards artifacts and start the server
pnpm run dashboards-demo:build-and-run-all:esm
# Run the E2E tests on another terminal
./e2e-local.sh
# Run tests for the webpack dashboards demo only
./e2e-local.sh run '--project=dashboards-demo/*'
# Run tests for the ESM dashboards demo only
./e2e-local.sh run '--project=dashboards-demo-esm/*'
# To update the test snapshots that requires updating append `update`
./e2e-local.sh update
# To update all test snapshots, append `update-all`
./e2e-local.sh update-all
# To only update a specific test, append the file name. Glob patterns are supported.
./e2e-local.sh update <test-file-name>
# To run specific static tests, use --grep and restrict to the static spec:
./e2e-local.sh run --grep 'buttons/buttons|badges/badges'
Available parameters for e2e-local.sh:
.e2e-local.sh [run|a11y|vrt|update|update-all] [test-file-name]
# Environment variables:
# - CONTAINER_ENGINE: Override the container engine command (default: podman)
# - PORT: Override the port for the example application (default: 4200)
# - LOCAL_ADDRESS: Override the local address for the example application (default: localhost)
Use Docker instead of Podman¶
To use Docker, override the default container engine:
CONTAINER_ENGINE=docker ./e2e-local.sh
On Linux, Podman avoids the root-owned files that Docker can create when updating screenshots.
Using Rancher Desktop on Windows instead of Docker¶
Setup notes for Rancher Desktop on Windows:
- Install WSL 2
- Download and install Rancher Desktop
- Start Rancher Desktop and tick the "Enable networking tunnel" checkbox under File > Preferences > Network
To use Rancher's Docker engine, override the default container engine:
CONTAINER_ENGINE=docker ./e2e-local.sh
Note: In case of high CPU usage, there might be an issue with the Remote Desktop service or Vmmem using lots of CPU in idle state. If you don't need GUI apps then you can disable WSLg which should resolve the issue:
- Create the file
%USERPROFILE%\.wslconfigif it doesn't already exist and add the following:
[wsl2]
guiApplications=false
- Restart WSL by running wsl --shutdown
Documentation¶
We use Zensical to build the documentation. To have visible example code, run the example application first.
# Serve the documentation locally (without API documentation)
pnpm run docs:serve
Open the documentation at http://localhost:8000. The documentation and embedded examples both use localhost to avoid cross-site browser storage restrictions.
For details on how the documentation is built, see the documentation architecture.
API documentation¶
# Extract API data and generate reference pages into docs/api/ (gitignored, do not edit)
pnpm run docs:generate-api
# Build the site with API documentation
pnpm run docs:build:api
# Preview the site with API documentation
pnpm run docs:serve:api
# Fast build without API documentation
pnpm run docs:build
Rerun docs:generate-api when library sources change. The preview does not re-extract APIs or regenerate reference pages. The script runs angular-api-docs extract with the root api-docs.config.ts, and then runs uv run angular-api-docs-zensical generate-pages with the settings under extra.element_docs in mkdocs.yml. To regenerate only the JSON artifacts, run pnpm exec angular-api-docs extract. If the JSON is already current and you only need to regenerate the reference pages, run uv run angular-api-docs-zensical generate-pages.
Checks¶
# Unit tests
CI=true pnpm run docs:test
# Python tests
pnpm run docs:test:py
General writing style guide¶
To ensure clarity and consistency, follow these writing style guidelines:
- Use concise, straightforward language.
- Avoid jargon unless necessary. If using technical terms, provide a brief explanation.
- Tailor the tone to be professional yet approachable, with a focus on helping users find the information they're looking for.
Capitalization and formatting¶
Element uses sentence case for all text. This means:
- Capitalize only the first word of a sentence or phrase.
- Names (e.g., Siemens, Switzerland, Element) and acronyms (e.g., FAQ, API) must always be capitalized.
- Avoid unnecessary capitalization for emphasis or decoration.
- Component names are also written in sentence case and should not be capitalized.
Use bullet points for lists, but avoid excessive nesting.
Chapter structure¶
Each chapter must include:
- Introduction: A brief overview of the component purpose.
- Usage section:
- What it does: Explain the component's functionality, role, and variations.
- When to use: Outline ideal scenarios and when it’s not suitable.
- Best practices: Provide actionable tips for effective and accessible usage.
- Design section: Highlight key design elements, visuals, and behavior across states.
- Code section: Include implementation examples, API references, and integration tips.
Code section¶
Embed the API for relevant components, directives, services, pipes, and types instead of linking to it. Put API tags on their own lines, outside prose paragraphs. Export local APIs through the public entry point declared in ng-package.json. The compiler extractor discovers those exports automatically; no documentation barrel or separate documentation tsconfig is needed.
To enhance the docs with live examples and API specs, use these tags in the Markdown files:
<si-docs-component example="si-example-1/si-example-1"></si-docs-component>
The path in the example is relative from the example base url and only requires the subfolder and example name.<si-docs-api component="SiExampleComponent"></si-docs-api>To show the input parameters, output parameters and public attributes of your component, enter the class name in thecomponentattribute.<si-docs-api directive="SiExampleDirective"></si-docs-api>
To show the input parameters, output parameters and public attributes of your directive, enter the class name in thedirectiveattribute.<si-docs-api injectable="SiExampleService"></si-docs-api>
To show the public attributes of your service, enter the class name in theinjectableattribute.<si-docs-type name="SiExampleInterface"></si-docs-type>
To show the attributes of your interface or class, enter the type name in thenameattribute.<si-docs-types></si-docs-types>
To show the types of the input and output parameters of your component, only works in combination with thesi-docs-apitag. Includes the types for all components and directives documented in the same file. Can therefore only be used once per file. It should always be used to get better types documentation resolution.
To document these tags literally, put them in fenced or inline code. Literal code and comments are not interpreted as active API or example requests.
Except where otherwise noted, content on this site is licensed under MIT License.