From 6459ab511eaf93b1cc906a9d266be36d49d97f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9vesque?= Date: Sat, 14 Dec 2024 16:05:47 -0500 Subject: [PATCH] add markdown scope to contents of doc attributes --- CHANGELOG.md | 7 ++++ syntaxes/elixir.json | 87 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 428bdeb..1fe38c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [Unreleased] + +### Added + +- Identify contents of documentation attributes (`@doc`, `@moduledoc` and + `@typedoc`) as Markdown, thus enabling Markdown syntax highlighting. + ## [0.0.18] ### Fixed diff --git a/syntaxes/elixir.json b/syntaxes/elixir.json index f244e3f..f2febb2 100644 --- a/syntaxes/elixir.json +++ b/syntaxes/elixir.json @@ -20,71 +20,136 @@ "name": "meta.module.elixir" }, { - "begin": "@(module|type)?doc (~s)?\"\"\"", + "begin": "@(?:module|type)?doc (?:~s)?\"\"\"", "comment": "@doc with interpolated heredocs", "end": "\\s*\"\"\"", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" + }, + { + "include": "text.html.markdown" } ] }, { - "begin": "@(module|type)?doc ~s'''", + "begin": "@(?:module|type)?doc ~s'''", "comment": "@doc with interpolated single quoted heredocs", "end": "\\s*'''", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" + }, + { + "include": "text.html.markdown" } ] }, { - "begin": "@(module|type)?doc ~S\"\"\"", + "begin": "@(?:module|type)?doc ~S\"\"\"", "comment": "@doc with heredocs is treated as documentation", "end": "\\s*\"\"\"", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#escaped_char" + }, + { + "include": "text.html.markdown" } ] }, { - "begin": "@(module|type)?doc ~S'''", + "begin": "@(?:module|type)?doc ~S'''", "comment": "@doc with heredocs is treated as documentation", "end": "\\s*'''", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#escaped_char" + }, + { + "include": "text.html.markdown" } ] }, { "comment": "@doc false is treated as documentation", - "match": "@(module|type)?doc false", + "match": "@(?:module|type)?doc false", "name": "comment.documentation.false" }, { - "begin": "@(module|type)?doc \"", + "begin": "@(?:module|type)?doc \"", "comment": "@doc with string is treated as documentation", "end": "\"", - "name": "comment.documentation.string", + "name": "documentation.string", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" + }, + { + "include": "text.html.markdown" } ] },