Skip to content

Commit 8435632

Browse files
committed
Add files
1 parent 9b4ee10 commit 8435632

2 files changed

Lines changed: 87 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ST3_apiDocAutocompletion
22
========================
33

4-
A plugin for Sublime Text 3 that adds apiDoc tags to list of code completion suggestions
4+
A plugin for Sublime Text 3 that adds apiDoc tags to list of code completion suggestions.

apiDocAutocompletion.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Sublime Text 3 Plugin
2+
# apiDocAutocompletion adds apiDoc tags to list of code completion suggestions.
3+
# Project: https://github.com/DWand/ST3_apiDocAutocompletion
4+
# License: MIT
5+
6+
import sublime
7+
import sublime_plugin
8+
9+
class apiDocAutocompletion(sublime_plugin.EventListener):
10+
_suggestions = [
11+
("@api\tapiDoc", "@api {${1:method}} ${2:path} ${3:[title]}"),
12+
("@apiDefine\tapiDoc", "@apiDefine ${1:name} ${2:[title]}\n* ${3:[description]}"),
13+
("@apiDescription\tapiDoc", "@apiDescription ${1:text}"),
14+
("@apiError\tapiDoc", "@apiError ${1:[(group)]} ${2:[{type\}]} ${3:field} ${4:[description]}"),
15+
("@apiErrorExample\tapiDoc", "@apiErrorExample ${1:[{type\}]} ${2:[title]}\n* ${3:example}"),
16+
("@apiExample\tapiDoc", "@apiExample ${1:[{type\}]} ${2:title}\n* ${3:example}"),
17+
("@apiGroup\tapiDoc", "@apiGroup ${1:name}"),
18+
("@apiHeader\taiDoc", "@apiHeader ${1:[(group)]} ${2:[{type\}]} ${3:[field=defaultValue]} ${4:[description]}"),
19+
("@apiHeaderExample\tapiDoc", "@apiHeaderExample ${1:[{type\}]} ${2:[title]}\n* ${3:example}"),
20+
("@apiIgnore\tapiDoc", "@apiIgnore ${1:[hint]}"),
21+
("@apiName\tapiDoc", "@apiName ${1:name}"),
22+
("@apiParam\tapiDoc", "@apiParam ${1:[(group)]} ${2:[{type\}]} ${3:[field=defaultValue]} ${4:[description]}"),
23+
("@apiParamExample\tapiDoc", "@apiParamExample ${1:[{type\}]} ${2:[title]}\n* ${3:example}"),
24+
("@apiPermission\tapiDoc", "@apiPermission ${1:name}"),
25+
("@apiSampleRequest\tapiDoc", "@apiSampleRequest ${1:url}"),
26+
("@apiSuccess\tapiDoc", "@apiSuccess ${1:[(group)]} ${2:[{type\}]} ${3:field} ${4:[description]}"),
27+
("@apiSuccessExample\tapiDoc", "@apiSuccessExample ${1:[{type\}]} ${2:[title]}\n* ${3:example}"),
28+
("@apiUse\tapiDoc", "@apiUse ${1:name}"),
29+
("@apiVersion\tapiDoc", "@apiVersion ${1:version}"),
30+
("@apiDefineErrorStructure\tapiDoc [deprecated]", "@apiDefineErrorStructure ${1:name}"),
31+
("@apiDefineHeaderStructure\tapiDoc [deprecated]", "@apiDefineHeaderStructure ${1:name}"),
32+
("@apiDefinePermission\tapiDoc [deprecated]", "@apiDefinePermission ${1:name} ${2:[title]}\n* ${3:[description]}"),
33+
("@apiDefineStructure\tapiDoc [deprecated]", "@apiDefineStructure ${1:name}"),
34+
("@apiDefineSuccessStructure\tapiDoc [deprecated]", "@apiDefineSuccessStructure ${1:name}"),
35+
("@apiErrorStructure\tapiDoc [deprecated]", "@apiErrorStructure ${1:name}"),
36+
("@apiErrorTitle\tapiDoc [deprecated]", "@apiErrorTitle (${1:group}) ${2:description}"),
37+
("@apiGroupDescription\tapiDoc [deprecated]", "@apiGroupDescription ${1:text}"),
38+
("@apiHeaderStructure\tapiDoc [deprecated]", "@apiHeaderStructure ${1:name}"),
39+
("@apiHeaderTitle\tapiDoc [deprecated]", "@apiHeaderTitle (${1:group}) ${2:description}"),
40+
("@apiParamTitle\tapiDoc [deprecated]", "@apiParamTitle (${1:group}) ${2:description}"),
41+
("@apiStructure\tapiDoc [deprecated]", "@apiStructure ${1:name}"),
42+
("@apiSuccessStructure\tapiDoc [deprecated]", "@apiSuccessStructure ${1:name}"),
43+
("@apiSuccessTitle\tapiDoc [deprecated]", "@apiSuccessTitle (${1:group}) ${2:description}"),
44+
]
45+
46+
def on_query_completions(self, view, prefix, locations):
47+
48+
# Block comment scopes:
49+
# C#:
50+
# source.cs comment.block.source.cs
51+
# Go:
52+
# source.go comment.block.go
53+
# Dart:
54+
# -
55+
# Java:
56+
# source.java comment.block.documentation.javadoc meta.documentation.comment.javadoc text.html
57+
# JavaScript:
58+
# source.js comment.block.documentation.js
59+
# PHP:
60+
# text.html.basic source.php.embedded.block.html comment.block.documentation.phpdoc.php
61+
# CoffeeScript:
62+
# source.coffee comment.block.coffee
63+
# Erlang:
64+
# source.erlang
65+
# Perl:
66+
# source.perl meta.comment.full-line.perl comment.line.number-sign.perl
67+
# source.perl comment.block.documentation.perl
68+
# Python:
69+
# source.python string.quoted.double.block.python
70+
# Ruby:
71+
# source.ruby comment.block.documentation.ruby
72+
73+
target_scopes = [
74+
"comment.block",
75+
"source.perl meta.comment.full-line.perl comment.line.number-sign.perl",
76+
"source.python string.quoted.double.block.python",
77+
"source.erlang"
78+
]
79+
80+
location = locations[0]
81+
current_scope = view.scope_name(location)
82+
83+
if any(scope in current_scope for scope in target_scopes) == True:
84+
return apiDocAutocompletion._suggestions
85+
else:
86+
return []

0 commit comments

Comments
 (0)