Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstrings as per Erlang/OTP 27 #13

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 219 additions & 0 deletions Erlang.plist
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,219 @@
</dict>
</array>
</dict>
<key>docstring</key>
<dict>
<key>comment</key>
<string>It is possible to use more than 3 double quote characters as beginning and closing sequences (must be the same). Cover 3-9 characters here.</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#docstring3</string>
</dict>
<dict>
<key>include</key>
<string>#docstring4</string>
</dict>
<dict>
<key>include</key>
<string>#docstring5</string>
</dict>
<dict>
<key>include</key>
<string>#docstring6</string>
</dict>
<dict>
<key>include</key>
<string>#docstring7</string>
</dict>
<dict>
<key>include</key>
<string>#docstring8</string>
</dict>
<dict>
<key>include</key>
<string>#docstring9</string>
</dict>
</array>
</dict>
<key>docstring3</key>
<dict>
<key>begin</key>
<string>(?&lt;!")(["]{3}\s*)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.begin.erlang</string>
</dict>
</dict>
<key>comment</key>
<string>Only whitespace characters are allowed after the beggining and before the closing sequences and those cannot be in the same line</string>
<key>end</key>
<string>^(\s*["]{3})(?!")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.end.erlang</string>
</dict>
</dict>
<key>name</key>
<string>string.string.docstring.multi.erlang</string>
</dict>
<key>docstring4</key>
<dict>
<key>begin</key>
<string>(?&lt;!")(["]{4}\s*)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.begin.erlang</string>
</dict>
</dict>
<key>end</key>
<string>^(\s*["]{4})(?!")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.end.erlang</string>
</dict>
</dict>
<key>name</key>
<string>string.string.docstring.multi.erlang</string>
</dict>
<key>docstring5</key>
<dict>
<key>begin</key>
<string>(?&lt;!")(["]{5}\s*)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.begin.erlang</string>
</dict>
</dict>
<key>end</key>
<string>^(\s*["]{5})(?!")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.end.erlang</string>
</dict>
</dict>
<key>name</key>
<string>string.string.docstring.multi.erlang</string>
</dict>
<key>docstring6</key>
<dict>
<key>begin</key>
<string>(?&lt;!")(["]{6}\s*)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.begin.erlang</string>
</dict>
</dict>
<key>end</key>
<string>^(\s*["]{6})(?!")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.end.erlang</string>
</dict>
</dict>
<key>name</key>
<string>string.string.docstring.multi.erlang</string>
</dict>
<key>docstring7</key>
<dict>
<key>begin</key>
<string>(?&lt;!")(["]{7}\s*)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.begin.erlang</string>
</dict>
</dict>
<key>end</key>
<string>^(\s*["]{7})(?!")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.end.erlang</string>
</dict>
</dict>
<key>name</key>
<string>string.string.docstring.multi.erlang</string>
</dict>
<key>docstring8</key>
<dict>
<key>begin</key>
<string>(?&lt;!")(["]{8}\s*)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.begin.erlang</string>
</dict>
</dict>
<key>end</key>
<string>^(\s*["]{8})(?!")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.end.erlang</string>
</dict>
</dict>
<key>name</key>
<string>string.string.docstring.multi.erlang</string>
</dict>
<key>docstring9</key>
<dict>
<key>begin</key>
<string>(?&lt;!")(["]{9}\s*)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.begin.erlang</string>
</dict>
</dict>
<key>end</key>
<string>^(\s*["]{9})(?!")</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.docstring.end.erlang</string>
</dict>
</dict>
<key>name</key>
<string>string.string.docstring.multi.erlang</string>
</dict>
<key>everything-else</key>
<dict>
<key>patterns</key>
Expand Down Expand Up @@ -600,6 +813,10 @@
<key>include</key>
<string>#atom</string>
</dict>
<dict>
<key>include</key>
<string>#docstring</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
Expand Down Expand Up @@ -2593,6 +2810,8 @@
<string>punctuation.definition.escape.erlang</string>
</dict>
</dict>
<key>comment</key>
<string>escape sequence</string>
<key>match</key>
<string>(\\)([bdefnrstv\\'"]|(\^)[@-_a-z]|[0-7]{1,3}|x[\da-fA-F]{2})</string>
<key>name</key>
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ from _Ben Hockley_.
from Github and use below commands: (On Windows use e.g. WSL)

```bash
/path/to/plist_yaml.py Erlang.plist Erlang.yaml
/path/to/plistyamlplist.py Erlang.plist Erlang.yaml
# Edit YAML file here ... then if you are ready convert back to PLIST
/path/to/yaml_plist.py Erlang.yaml Erlang.plist
/path/to/plistyamlplist.py Erlang.yaml Erlang.plist
```

> Note:
> Please read
> [Issue with Python 3.11](https://github.com/grahampugh/plist-yaml-plist/issues/15)
> if you get a strange error when convert PLIST to YAML or vice versa.

Commit your updates on `Erlang.plist` and ignode `Erlang.yaml`.

To test the grammar we use
Expand Down
33 changes: 33 additions & 0 deletions tests/snap/docstring.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-module(docstring).

-export([f/0]).

-doc """
Docstring examples
""".
f() ->
"""
Line "1"
Line "2"
""" = "Line \"1\"
Line \"2\"",
X = lists:seq(1,3), % just to check is syntax highlight is still ok

"""
First line starting with two spaces
Not escaped: "\t \r \xFF" and """

""" = " First line starting with two spaces
Not escaped: \"\\t \\r \\xFF\" and \"\"\"
",
X = lists:seq(1,3), % just to check is syntax highlight is still ok

"""""
""""
FIXME: previous line is not a closing delimiter because opening-closing delimiter have five double quote characters
""""" = "\"\"\"\"",
X = lists:seq(1,3), % just to check is syntax highlight is still ok

ok.

-define(THIS_IS_THE_END, "end"). % just to check is syntax highlight is still ok
Loading