Vale CMS Need more than a rule playground? Explore
Asset Explorer

Python

Comments and docstrings in Python source, read as Markdown.

view tree-sittercode Source

Getting started

Save the file as config/views/Python.yml under your StylesPath, then:

[*.py]
BasedOnStyles = Vale

View = Python

Python.yml

Pull named scopes out of a file Vale can’t otherwise parse.
# Python source: comments and docstrings, read as Markdown.
#
#   [*.py]
#   BasedOnStyles = Vale
#   View = Python
engine: tree-sitter
scopes:
  - name: comment
    expr: (comment)+ @comment
    type: md

  - name: docstring
    expr: |
      ((function_definition
        body: (block . (expression_statement (string) @docstring)))
      (#offset! @docstring 0 3 0 -3))
    type: md