# Contributing to dg-plantuml [日本語](CONTRIBUTING.ja.md) Thank you for your interest. Bug reports, ideas, translations and pull requests are welcome. ## Before you start - For bugs and requests, please open an [issue](https://github.com/akiratamcat/joplin-plugin-dg-plantuml/issues) first. - For security problems, do not open a public issue. See [SECURITY.md](SECURITY.md). - The design is described in [docs/design.ja.md](docs/design.ja.md) (in Japanese). The documents in `docs/` are written only in Japanese (`*.ja.md`): - `design.ja.md`: the design document (requirements, architecture, tests, release). - `lessons-learned.ja.md`: things found in investigations and tests that changed the design or the code (engine quirks, Joplin's behaviour). - `release.ja.md`: the release procedure and the checks before pushing to GitHub. - `owner-decisions.ja.md`: decisions made by the maintainer. ## Development environment - Node.js 22 or later and npm (the CI uses Node.js 22) - Google Chrome (used by the rendering tests; no browser download is needed) - Joplin desktop 3.1 or later, to try the plugin ```sh npm ci npm run dist # builds publish/io.github.akiratamcat.dg-plantuml.jpl ``` Install the `.jpl` with "Install from file" on Joplin's plugin screen (Tools → Options → Plugins; on macOS, Joplin → Settings → Plugins), then restart Joplin. ## Project layout | Path | Contents | | ---- | -------- | | `src/index.ts` | Main plugin script: settings, content scripts, messages from the viewer | | `src/contentScript/` | Markdown-it plugin, viewer script (rendering, cache, toolbar), engine loader, CodeMirror plugin | | `src/shared/` | Code used by both sides (fence parsing, tokenizer, messages) | | `src/i18n/` | gettext implementation; `catalog/catalogs.json` is generated by `npm run i18n:compile` | | `src/presets/` | Built-in styles and the list of PlantUML themes | | `vendor/plantuml/` | The PlantUML engine, copied unchanged (see `SOURCE.md`) | | `locales/` | Translations (gettext PO files) | | `scripts/` | i18n, license and publish checks | | `tests/` | Unit tests; `tests/render/` rendering tests; `tests/manual/` manual test procedures and records (`*.ja.md`, in Japanese) and test notes to paste into Joplin (`*.md`, in English) | ## Commands | Command | What it does | | ------- | ------------ | | `npm run dist` | Builds the plugin package (`publish/*.jpl`) | | `npm test` | Unit tests, then the rendering tests | | `npm run test:unit` | Compiles and checks the translations, checks the licenses, then runs the unit tests and the static network check (no build needed) | | `npm run test:render` | Builds the plugin, then renders diagrams in headless Chrome with the network blocked | | `npm run typecheck` | TypeScript type check | | `npm run lint` | ESLint | | `npm run i18n:extract` | Updates `locales/plantuml.pot` and all PO files from the source code | | `npm run i18n:check` | Checks the PO files (placeholders, plural forms, fuzzy entries) | | `npm run i18n:compile` | Builds `src/i18n/catalog/catalogs.json` from the PO files (run by `dist`, `test:unit` and `typecheck`) | | `npm run notices` | Rebuilds `THIRD_PARTY_NOTICES.md` and `THIRD_PARTY_NOTICES.ja.md` | | `npm run readme` | Copies `README.ja.md` into the Japanese half of `README.md` | | `npm run readme:check` | Checks that the Japanese half of `README.md` matches `README.ja.md` (run by `test:unit`) | | `npm run licenses:check` | Checks the licenses of the bundled packages and that the notices and version lists are up to date | | `npm run check:publish` | Checks the branch history before pushing to GitHub (emails, files that must not be published, secrets). Maintainer use; see `docs/release.ja.md` | Please run `npm test`, `npm run typecheck` and `npm run lint` before you open a pull request. To use another Chromium build for the rendering tests, set `DG_CHROME_PATH` to its executable. ## Branches and pull requests The project uses GitHub Flow. - `main` is the only long-lived branch and is always ready for a release. Releases are tags `vX.Y.Z` on `main`. - Create a branch from `main` with a prefix: `feature/…` (new or changed features), `fix/…` (bug fixes) or `docs/…` (documents only). - Open a pull request to `main`. It can be merged when the CI passes (lint, type check, and the tests on Windows, macOS and Linux). The maintainer's own changes go through pull requests too. - Pull requests are merged with a merge commit (no squash or rebase merge), so each piece of work stays visible in the history. - Merged branches are deleted (GitHub does it automatically). Their commits stay in `main`. - Fixes for a released version are made on a `fix/…` branch from `main` and released as a new PATCH version. Older versions get no fixes. - `spike/…` branches are throw-away experiments: they are not merged and not pushed. ## Rules - **No network access.** The plugin must not make network requests (see the README). Do not add code or dependencies that do. The static check (`tests/network.test.ts`) fails on new network code. - **The PlantUML engine** in `vendor/plantuml/` is kept unchanged. It is updated only for security fixes or needed bug fixes. The update steps are in `vendor/plantuml/SOURCE.md`. - **Dependencies** are pinned to exact versions. A package that ends up in the plugin needs a license from the allowlist in `scripts/check-licenses.mjs`, and an entry in `scripts/notices.mjs` and `src/thirdParty.ts`. - **Do not copy code from PlantUML itself** (the Java project). Parts of it are GPL, and this plugin is MIT. - **Documents**: the files at the top of the repository have an English and a Japanese version (`*.ja.md`); please update both, or say in the pull request which one needs a translation. GitHub shows only `README.md`, so it holds the English text and, after it, a copy of `README.ja.md`: edit `README.ja.md` and run `npm run readme`, never the Japanese half of `README.md` itself. - **Changelog**: write each change in both `CHANGELOG.md` and `CHANGELOG.ja.md`. The release notes on GitHub are made from both (English first, then Japanese). ## Translations Translations are gettext PO files in `locales/` (`ja.po`, `de.po`...), so they can be edited with Poedit or any text editor. The current translations were made with generative AI, so corrections by native speakers are very welcome. - To correct a translation, edit the `msgstr` in `locales/.po` and run `npm run i18n:check`. - Keep placeholders such as `{line}` and `{name}` as they are. Words like PlantUML, Joplin, `@startuml` and `\n` are not translated. Notes for translators are the `#.` comments. - After changing texts in the source code, run `npm run i18n:extract` to update `locales/plantuml.pot` and all PO files. - A new language needs an entry in `scripts/i18n-common.mjs` and in `src/i18n/gettext.ts` (plural rules). Untranslated texts are shown in English. ## License of contributions dg-plantuml is released under the MIT License. By submitting a contribution (code, translations, documentation), you agree that it is provided under the MIT License. ## Generative AI This project is developed with extensive use of generative AI (Anthropic's Claude), and the maintainer reviews every change. Generative AI is not needed to work on it: the documents and the commands above are all you need. You may use generative AI for your contribution, but please: - review and test the result yourself before you submit it, and - say in the pull request that you used generative AI, and for what.