# tree-sitter-javadoc
Javadoc grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
## About
Features:
* Complete old-school HTML (`/**`)
* Basic new-school Markdown (`///`) support
* Highlight queries, especially for those important/pesky `@see` and `@link` references
* `@nospell` set for javadocs syntax regions, so you don't have to turn spellcheck off anymore
* Injection queries for `@snippet`, `@value`
* Support for custom inline and block doclet tags
* Tested on heaps of java code, [popular open source codebases](https://github.com/rmuir/tree-sitter-javadoc/tree/main/injection_tests)
* Not perfect, but javadocs parsing is a dirty business
## Neovim Installation (for use in your editor)
Install [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter), then from neovim:
```
:TSInstall java javadoc html css printf comment
```
It is recommended to install at least these parsers for treesitter support of java code.
## Bindings Installation (for development)
Bindings are published to `pypi`, `npm`, and `crates.io` as `tree-sitter-javadoc`.
Wasm and source code artifacts are published to [GitHub releases](https://github.com/rmuir/tree-sitter-javadoc/releases)
## Customize
You can customize highlighting by creating custom [query](https://neovim.io/doc/user/treesitter.html#_treesitter-queries) files in `~/.config/nvim/queries/`:
### Example customization: conventions-based highlighting
This `;; extends` the default queries, and adds additional queries based on standard coding conventions.
Many treesitter parsers do this, including java, but neovim is trying to move away from it.
If you use an LSP with semantic token support, you don't need this. Otherwise, it might be useful to you.
`~/.config/nvim/queries/javadoc/highlights.scm`:
```tsq
;; extends
; Capitalized methods in javadoc references are treated as constructors.
(((method
(identifier) @constructor)
(#lua-match? @constructor "^[A-Z]")))
; Screaming-case members are treated as constants.
((member
(identifier) @constant)
(#lua-match? @constant "^[A-Z_][A-Z0-9_]+$"))
; Camel-case members are treated as types.
((member
(identifier) @type)
(#lua-match? @type "^[A-Z].*[a-z]"))
```
### Example customization: disable HTML and markdown highlighting
The default highlighting incorporates highlighting of HTML and markdown tags via their respective parsers.
For a more minimal approach with just highlighting of block and inline tags, you can override the injections.
`~/.config/nvim/queries/javadoc/injections.scm`:
```tsq
; overriding with an empty query file to disable injections
```
## Screenshot of highlights

Raw data
{
"_id": null,
"home_page": null,
"name": "tree-sitter-javadoc",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "incremental, parsing, tree-sitter, javadoc",
"author": null,
"author_email": "Robert Muir <rmuir@apache.org>",
"download_url": "https://files.pythonhosted.org/packages/79/d4/f6eb588a8a7e1a9cd259cd9566ba93f330e3cae1b615ffa45d011c592948/tree_sitter_javadoc-0.2.1.tar.gz",
"platform": null,
"description": "# tree-sitter-javadoc\n\nJavadoc grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)\n\n## About\n\nFeatures:\n* Complete old-school HTML (`/**`)\n* Basic new-school Markdown (`///`) support\n* Highlight queries, especially for those important/pesky `@see` and `@link` references\n* `@nospell` set for javadocs syntax regions, so you don't have to turn spellcheck off anymore\n* Injection queries for `@snippet`, `@value`\n* Support for custom inline and block doclet tags\n* Tested on heaps of java code, [popular open source codebases](https://github.com/rmuir/tree-sitter-javadoc/tree/main/injection_tests)\n* Not perfect, but javadocs parsing is a dirty business\n\n## Neovim Installation (for use in your editor)\n\nInstall [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter), then from neovim:\n```\n:TSInstall java javadoc html css printf comment\n```\nIt is recommended to install at least these parsers for treesitter support of java code.\n\n## Bindings Installation (for development)\n\nBindings are published to `pypi`, `npm`, and `crates.io` as `tree-sitter-javadoc`.\nWasm and source code artifacts are published to [GitHub releases](https://github.com/rmuir/tree-sitter-javadoc/releases)\n\n## Customize\n\nYou can customize highlighting by creating custom [query](https://neovim.io/doc/user/treesitter.html#_treesitter-queries) files in `~/.config/nvim/queries/`:\n\n### Example customization: conventions-based highlighting\n\nThis `;; extends` the default queries, and adds additional queries based on standard coding conventions.\nMany treesitter parsers do this, including java, but neovim is trying to move away from it.\nIf you use an LSP with semantic token support, you don't need this. Otherwise, it might be useful to you.\n\n`~/.config/nvim/queries/javadoc/highlights.scm`:\n```tsq\n;; extends\n\n; Capitalized methods in javadoc references are treated as constructors.\n(((method\n (identifier) @constructor)\n (#lua-match? @constructor \"^[A-Z]\")))\n\n; Screaming-case members are treated as constants.\n((member\n (identifier) @constant)\n (#lua-match? @constant \"^[A-Z_][A-Z0-9_]+$\"))\n\n; Camel-case members are treated as types.\n((member\n (identifier) @type)\n (#lua-match? @type \"^[A-Z].*[a-z]\"))\n```\n\n### Example customization: disable HTML and markdown highlighting\n\nThe default highlighting incorporates highlighting of HTML and markdown tags via their respective parsers.\nFor a more minimal approach with just highlighting of block and inline tags, you can override the injections.\n\n`~/.config/nvim/queries/javadoc/injections.scm`:\n```tsq\n; overriding with an empty query file to disable injections\n```\n\n## Screenshot of highlights\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parser for Javadoc documentation comments",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/rmuir/tree-sitter-javadoc"
},
"split_keywords": [
"incremental",
" parsing",
" tree-sitter",
" javadoc"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "56d5e5a9540e0ecdb1dd8d317e5d5a806137b7edc692f76c8555cbf16e7aec4f",
"md5": "83469d329c5df3b43fed2b30d3be9e36",
"sha256": "2a8d91418e179b267607739d08e5e54158895588c76069f88a00d0c9f9e80056"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1-cp310-abi3-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "83469d329c5df3b43fed2b30d3be9e36",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 33737,
"upload_time": "2025-07-13T21:16:35",
"upload_time_iso_8601": "2025-07-13T21:16:35.207144Z",
"url": "https://files.pythonhosted.org/packages/56/d5/e5a9540e0ecdb1dd8d317e5d5a806137b7edc692f76c8555cbf16e7aec4f/tree_sitter_javadoc-0.2.1-cp310-abi3-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e7732bef2f5bd2ee005352e19a3e9743931e1c640d778e0bacd745d41596091c",
"md5": "077b30b005d22b41b2406beafd135918",
"sha256": "c024319c47b910728db2a0d7ea4d8f49901742be98e317d42cff0361bd17db74"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1-cp310-abi3-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "077b30b005d22b41b2406beafd135918",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 34915,
"upload_time": "2025-07-13T21:16:36",
"upload_time_iso_8601": "2025-07-13T21:16:36.459148Z",
"url": "https://files.pythonhosted.org/packages/e7/73/2bef2f5bd2ee005352e19a3e9743931e1c640d778e0bacd745d41596091c/tree_sitter_javadoc-0.2.1-cp310-abi3-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7ec0ede35405061024319df759fd095eb43010a0a723efc8ec7a1f3bb76987cb",
"md5": "1d15f3c18c725d54b8713cef9697c5df",
"sha256": "ef3a260e04b0eb3ed83803842c93192ddd18f9df65a31a69e8e7fa940bb614f4"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "1d15f3c18c725d54b8713cef9697c5df",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 65897,
"upload_time": "2025-07-13T21:16:37",
"upload_time_iso_8601": "2025-07-13T21:16:37.633311Z",
"url": "https://files.pythonhosted.org/packages/7e/c0/ede35405061024319df759fd095eb43010a0a723efc8ec7a1f3bb76987cb/tree_sitter_javadoc-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e5e01c8122e08f3917901f75d241c7ddc16459ff2e70733beee5ea83f8952cbe",
"md5": "2dc36cbf9b47794bae0df9eb88424878",
"sha256": "383eda990a94b0872d2079a4ea970a1ef99422866ff10261469bb176e835ebd9"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "2dc36cbf9b47794bae0df9eb88424878",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 48086,
"upload_time": "2025-07-13T21:16:38",
"upload_time_iso_8601": "2025-07-13T21:16:38.827044Z",
"url": "https://files.pythonhosted.org/packages/e5/e0/1c8122e08f3917901f75d241c7ddc16459ff2e70733beee5ea83f8952cbe/tree_sitter_javadoc-0.2.1-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "027df03143649b7a64467e9f860a83477433dc423c8e93851f4a840d32afd92b",
"md5": "f400ca9f1bae8cc0eda242e027c59d25",
"sha256": "dce37cde6a18daf1f944aea189bb9a99872e98c3fc25f7642c17ca3d8c0f375d"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "f400ca9f1bae8cc0eda242e027c59d25",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 44440,
"upload_time": "2025-07-13T21:16:39",
"upload_time_iso_8601": "2025-07-13T21:16:39.831219Z",
"url": "https://files.pythonhosted.org/packages/02/7d/f03143649b7a64467e9f860a83477433dc423c8e93851f4a840d32afd92b/tree_sitter_javadoc-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "aa3c82c94addf7539ac489f6071d2136ea884966cf682c8c36e5abb54e5de623",
"md5": "201afedbde23d434d7cba3c4e51b79ee",
"sha256": "0b1dca45bc8fa7717534cefc0b2a5f7ccaca15d80f6a9afe2cd98227c85f70b7"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1-cp310-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "201afedbde23d434d7cba3c4e51b79ee",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 36889,
"upload_time": "2025-07-13T21:16:41",
"upload_time_iso_8601": "2025-07-13T21:16:41.182354Z",
"url": "https://files.pythonhosted.org/packages/aa/3c/82c94addf7539ac489f6071d2136ea884966cf682c8c36e5abb54e5de623/tree_sitter_javadoc-0.2.1-cp310-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "131f8fce22e5de2641a1dd8ab7bbb7c8f2ad7f8433195ae492f880217b692d0c",
"md5": "60a3346af737fbc7de8aa4fd5164a339",
"sha256": "819c2ef6c85f41344a2412c76c57e633a96e0c6723fbaa53e01179df7779e47b"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1-cp310-abi3-win_arm64.whl",
"has_sig": false,
"md5_digest": "60a3346af737fbc7de8aa4fd5164a339",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 35175,
"upload_time": "2025-07-13T21:16:42",
"upload_time_iso_8601": "2025-07-13T21:16:42.459447Z",
"url": "https://files.pythonhosted.org/packages/13/1f/8fce22e5de2641a1dd8ab7bbb7c8f2ad7f8433195ae492f880217b692d0c/tree_sitter_javadoc-0.2.1-cp310-abi3-win_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "79d4f6eb588a8a7e1a9cd259cd9566ba93f330e3cae1b615ffa45d011c592948",
"md5": "c83deae1d9b32e2ec2ab2b245dc6cf55",
"sha256": "f28d97353cf97269717928152dcd8fb6a120e62ab488524435b660e446eab3db"
},
"downloads": -1,
"filename": "tree_sitter_javadoc-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "c83deae1d9b32e2ec2ab2b245dc6cf55",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 43183,
"upload_time": "2025-07-13T21:16:43",
"upload_time_iso_8601": "2025-07-13T21:16:43.781432Z",
"url": "https://files.pythonhosted.org/packages/79/d4/f6eb588a8a7e1a9cd259cd9566ba93f330e3cae1b615ffa45d011c592948/tree_sitter_javadoc-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-13 21:16:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rmuir",
"github_project": "tree-sitter-javadoc",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tree-sitter-javadoc"
}