|
1 | | -# Dev Docs |
| 1 | +# Developer documentation |
2 | 2 |
|
3 | | -Random notes and things to know useful for maintainers and contributors. |
| 3 | +Canonical reference for everyone working on the HyperFormula source code: maintainers, the internal team, and AI agents triggered by them. Everything a developer needs to know lives here or is linked from here. |
4 | 4 |
|
5 | | -## Definition of Done for the code changes |
| 5 | +## Quick links |
6 | 6 |
|
7 | | -Each change to the production code (bugfixes, new features, improvements) must include these elements. They must be present in the pull request BEFORE requesting the code review. |
| 7 | +- **[Building, testing, and linting](docs/guide/building.md)** — all `npm` commands and build outputs |
| 8 | +- **[Test suite](test/README.md)** — smoke tests and how to attach the private test suite |
| 9 | +- **[Public docs portal](https://hyperformula.handsontable.com/docs)** — main documentation |
| 10 | +- **[Docs README](docs/README.md)** — how to run the docs portal locally |
| 11 | +- **[Changelog](CHANGELOG.md)** |
| 12 | +- **[Pull request template](.github/pull_request_template.md)** |
8 | 13 |
|
9 | | -- changes to the production code |
10 | | - - including changes to all supported language packs in `src/i18n/languages` directory (if applicable) |
11 | | -- automatic tests |
12 | | - - for bugfixes: at least one test reproducing the bug |
13 | | - - for new features: a set of tests describing the feature specification precisely |
14 | | - - pull requests from external contributors should include tests in `tests/` directory (they will be moved to the private repository by the internal team) |
15 | | - - internal team adds tests directly to the private repository (through a separate pull request) |
16 | | -- updates to documentation related to the change |
| 14 | +## Repository layout |
| 15 | + |
| 16 | +``` |
| 17 | +. |
| 18 | +├── src/ # Source code |
| 19 | +│ ├── HyperFormula.ts # Main engine class, public API entry point |
| 20 | +│ ├── parser/ # Formula parsing (uses Chevrotain parser generator) |
| 21 | +│ ├── interpreter/ # Formula evaluation engine |
| 22 | +│ │ └── plugin/ # Built-in spreadsheet function plugins |
| 23 | +│ ├── DependencyGraph/ # Cell dependency tracking and recalculation order |
| 24 | +│ ├── CrudOperations.ts # Create/read/update/delete operations on sheets and cells |
| 25 | +│ └── i18n/ # Function-name translations per language |
| 26 | +├── test/ # Test suite |
| 27 | +├── docs/ # Public documentation portal (VuePress) |
| 28 | +│ ├── guide/ # Markdown guides (building, contributing, usage…) |
| 29 | +│ ├── api/ # API reference (generated from JSDoc) |
| 30 | +│ ├── .vuepress/ # VuePress configuration, theme, components |
| 31 | +│ └── README.md # How to run the docs portal locally |
| 32 | +├── script/ # Maintenance and release scripts |
| 33 | +├── .github/ # CI workflows, issue and PR templates |
| 34 | +├── DEV_DOCS.md # Canonical developer documentation (this file) |
| 35 | +├── AGENTS.md # Guidance for AI agents |
| 36 | +├── CONTRIBUTING.md # Guide for external contributors |
| 37 | +├── README.md # Project overview |
| 38 | +├── CHANGELOG.md |
| 39 | +├── LICENSE.txt |
| 40 | +├── package.json |
| 41 | +└── tsconfig.json |
| 42 | +``` |
| 43 | + |
| 44 | +## Architecture |
| 45 | + |
| 46 | +### Core modules |
| 47 | + |
| 48 | +- `src/HyperFormula.ts` — main engine class, public API entry point |
| 49 | +- `src/parser/` — formula parsing (uses the [Chevrotain](https://chevrotain.io/) parser generator) |
| 50 | +- `src/interpreter/` — formula evaluation engine |
| 51 | +- `src/DependencyGraph/` — cell dependency tracking and recalculation order |
| 52 | +- `src/CrudOperations.ts` — create/read/update/delete operations on sheets and cells |
| 53 | + |
| 54 | +### Function plugins (`src/interpreter/plugin/`) |
| 55 | + |
| 56 | +All spreadsheet functions are implemented as plugins extending `FunctionPlugin`. Each plugin: |
| 57 | + |
| 58 | +- declares an `implementedFunctions` static property mapping function names to metadata |
| 59 | +- uses the `runFunction()` helper for argument validation, coercion, and array handling |
| 60 | +- registers function translations in `src/i18n/languages/` |
| 61 | + |
| 62 | +## How to add a new function |
| 63 | + |
| 64 | +Adding a built-in function is similar to adding a [custom function](docs/guide/custom-functions.md), so that guide is a useful reference for the function-implementation patterns (argument metadata, return types, array handling). The built-in flow on top of that is: |
| 65 | + |
| 66 | +1. Create or modify a plugin in `src/interpreter/plugin/`. |
| 67 | +2. Add function metadata to `implementedFunctions`. |
| 68 | +3. Implement the function method. |
| 69 | +4. Add translations to all language files in `src/i18n/languages/`. |
| 70 | +5. Add tests in `test/unit/interpreter/`. |
| 71 | + |
| 72 | +## Code style |
| 73 | + |
| 74 | +- Prefer a functional approach where possible (`filter`, `map`, `reduce`). |
| 75 | +- Write self-documenting code: use meaningful names for classes, functions, and variables. Add code comments only when they explain intent the code itself cannot. |
| 76 | +- Add JSDoc to all classes and functions. |
| 77 | +- ESLint is the source of truth for formatting and code rules. Run `npm run lint` before submitting changes (see [building](docs/guide/building.md#run-the-linter)). |
| 78 | + |
| 79 | +## Definition of Done |
| 80 | + |
| 81 | +Each change to the production code (bugfix, new feature, or improvement) must include the following elements **before** requesting a code review: |
| 82 | + |
| 83 | +- Changes to the production code |
| 84 | + - including changes to all supported language packs in `src/i18n/languages` (if applicable) |
| 85 | +- Automatic tests |
| 86 | + - for bug fixes: at least one test reproducing the bug |
| 87 | + - for new features: a set of tests precisely describing the feature |
| 88 | + - pull requests from external contributors should include tests in the `test/` directory (they will be moved to the private repository by the internal team) |
| 89 | + - the internal team adds tests directly to the private repository (through a separate pull request) |
| 90 | +- Updates to documentation related to the change |
17 | 91 | - for breaking changes: a section in the migration guide |
18 | | -- technical documentation in the form of the jsdoc comments (high-level description of the concepts used in the more complex code fragments) |
19 | | -- changelog entry |
20 | | -- pull request description |
| 92 | +- Technical documentation in the form of JSDoc comments (high-level description of the concepts used in more complex code fragments) |
| 93 | +- Changelog entry |
| 94 | +- Pull request description |
| 95 | + |
| 96 | +## Internationalization and function translations |
| 97 | + |
| 98 | +HyperFormula supports internationalization and provides localized function names for all built-in languages. Translation files live in `src/i18n/languages/`. New functions must include translations for all built-in languages. |
21 | 99 |
|
22 | | -## Sources of the function translations |
| 100 | +When looking for the valid translations for new functions, try these sources: |
23 | 101 |
|
24 | | -HF supports internationalization and provides the localized function names for all built-in languages. When looking for the valid translations for the new functions, try these sources: |
25 | 102 | - https://support.microsoft.com/en-us/office/excel-functions-translator-f262d0c0-991c-485b-89b6-32cc8d326889 |
26 | 103 | - http://dolf.trieschnigg.nl/excel/index.php |
27 | 104 |
|
|
0 commit comments