diff --git a/Python/Comments.tmPreferences b/Python/Comments.tmPreferences
index 9ca609c7c5..eaafd5da10 100644
--- a/Python/Comments.tmPreferences
+++ b/Python/Comments.tmPreferences
@@ -19,6 +19,17 @@
value
:
+
+
+ name
+ TM_COMMENT_START_2
+ value
+ #:
+
diff --git a/Python/Python.sublime-syntax b/Python/Python.sublime-syntax
index ae047a15c5..b3f7668f27 100644
--- a/Python/Python.sublime-syntax
+++ b/Python/Python.sublime-syntax
@@ -364,6 +364,11 @@ contexts:
###[ COMMENTS ]###############################################################
comments:
+ # Special Sphinx comment syntax to denote documentation
+ # https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoattribute
+ - match: '#:'
+ scope: punctuation.definition.comment.python
+ push: comment-sphinxdoc-body
- match: \#
scope: punctuation.definition.comment.python
push:
@@ -375,6 +380,11 @@ contexts:
- match: \n
pop: 1
+ comment-sphinxdoc-body:
+ - meta_scope: comment.line.documentation.python
+ - match: \n
+ pop: 1
+
shebang:
- meta_include_prototype: false
- match: ^\#!
diff --git a/Python/tests/syntax_test_python.py b/Python/tests/syntax_test_python.py
index b3d3ed0472..9348d02a1b 100644
--- a/Python/tests/syntax_test_python.py
+++ b/Python/tests/syntax_test_python.py
@@ -68,6 +68,14 @@
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation
"""
+#: This is a prefixed "doc comment", supported by sphinx
+# <- comment.line.documentation.python punctuation.definition.comment.python
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.documentation.python
+#^ punctuation.definition.comment.python
+attribute = ... #: also supported on the same line
+# ^^ comment.line.documentation.python punctuation.definition.comment.python
+# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.documentation.python
+
r'''This is a syntax test file.
# <- storage.type.string - comment
#^^^ comment.block.documentation.python punctuation.definition.comment.begin.python