release 0.3.1

This commit is contained in:
geequlim
2017-09-22 23:57:26 +08:00
parent bc96a9462b
commit 4f0550ce86
12 changed files with 92126 additions and 87244 deletions

View File

@@ -1,5 +1,11 @@
# Change Log
### 0.3.1
* Update documentations with latest godot.
* Fix errors with run script and run project.
* Improve code completion with opening script file and constants.
* Some improvements for documentations.
### 0.3.0
* Add project root configuration settings as `GodotTools.godotProjectRoot` thanks Konstantin Zaitcev
* Add auto indent support for gdscript language

View File

@@ -53,6 +53,12 @@ Make sure you save your .gd file, then run "GodotTools: Update Workspace Symbols
## Release Notes
### 0.3.1
* Update documentations with latest godot.
* Fix errors with run script and run project.
* Improve code completion with opening script file and constants.
* Some improvements for documentations.
### 0.3.0
* Add project root configuration settings as `GodotTools.godotProjectRoot` thanks Konstantin Zaitcev
* Add auto indent support for gdscript language
@@ -66,11 +72,6 @@ Make sure you save your .gd file, then run "GodotTools: Update Workspace Symbols
* Enhanced syntax highlight with GDScript
* Enhanced code completion with GDScript
### 0.2.8
* Add godot 3.0 project support with configuration `GodotTools.parseTextScene` >= 3
* Add configuration `GodotTools.parseTextScene` to allow disable node path parsing
* Remove `GodotTools.editorServerPort` configuration
[Full change log](https://github.com/GodotExplorer/godot-tools/blob/master/CHANGELOG.md)
## TODOS:

2
doc/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
classes/*.xml
classes-*.xml

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -58,7 +58,7 @@ def main():
for cls in tree.getroot():
dictCls = parseClass(cls)
classes[dictCls['name']] = dictCls
jsonContent = json.dumps({"classes": classes, "version": "2.1.3"}, ensure_ascii=False, indent=2)
jsonContent = json.dumps({"classes": classes, "version": "2.1.4"}, ensure_ascii=False, indent=2)
print(jsonContent)
if __name__ == '__main__':

70
doc/xmldoc2json-3.0.py Executable file
View File

@@ -0,0 +1,70 @@
#!/usr/bin/python
import sys
import xml.etree.ElementTree as ET
import json
import os
def parseClass(data):
dictCls = dict(data.attrib)
dictCls['brief_description'] = data.find("brief_description").text.strip()
dictCls['description'] = data.find("description").text.strip()
dictCls['methods'] = []
for m in data.find("methods"):
dictCls['methods'].append(parseMethod(m))
dictCls['signals'] = []
for s in (data.find("signals") if data.find("signals") is not None else []):
dictCls['signals'].append(parseMethod(s))
dictCls['constants'] = []
for c in (data.find("constants") if data.find("constants") is not None else []):
dictCls['constants'].append(parseConstant(c))
dictCls['properties'] = []
for m in (data.find("members") if data.find("members") is not None else []):
dictCls['properties'].append(parseProperty(m))
dictCls['theme_properties'] = []
for thi in (data.find("theme_items") if data.find("theme_items") is not None else []):
dictCls['theme_properties'].append(parseProperty(thi))
return dictCls
def parseMethod(data):
dictMethod = dict(data.attrib)
dictMethod['description'] = data.find("description").text.strip()
dictMethod['return_type'] = data.find("return").attrib["type"] if data.find("return") is not None else ""
if "qualifiers" not in dictMethod: dictMethod["qualifiers"] = ""
dictMethod["arguments"] = []
for arg in data.iter('argument'):
dictMethod["arguments"].append(parseArgument(arg))
return dictMethod
def parseArgument(data):
dictArg = dict(data.attrib)
if "dictArg" in dictArg: dictArg.pop("index")
dictArg["default_value"] = dictArg["default"] if "default" in dictArg else ""
if "default" in dictArg: dictArg.pop("default")
return dictArg
def parseConstant(data):
dictConst = dict(data.attrib)
dictConst["description"] = data.text.strip()
return dictConst
def parseProperty(data):
dictProp = dict(data.attrib)
dictProp["description"] = data.text.strip()
return dictProp
def main():
if len(sys.argv) >=2 :
if os.path.isdir(sys.argv[1]):
classes = {}
for fname in os.listdir(sys.argv[1]):
f = os.path.join(sys.argv[1], fname)
tree = ET.parse(open(f, 'r'))
cls = tree.getroot()
dictCls = parseClass(cls)
classes[dictCls['name']] = dictCls
jsonContent = json.dumps({"classes": classes, "version": "3.0.alpha"}, ensure_ascii=False, indent=2)
print(jsonContent)
if __name__ == '__main__':
main()

View File

@@ -3,7 +3,7 @@
"displayName": "Godot Tools",
"icon": "newIcon.png",
"description": "Tools for game development with godot game engine",
"version": "0.3.0",
"version": "0.3.1",
"publisher": "geequlim",
"repository": "https://github.com/GodotExplorer/godot-tools",
"license": "MIT",

View File

@@ -123,7 +123,9 @@ class Config {
argstr += `${arg.type} ${arg.name}${arg.default_value.length>0?'='+arg.default_value:''}${m.arguments.indexOf(arg)==m.arguments.length-1?'':', '}`;
});
// mi.label=`${m.name}(${argstr}) ${m.qualifiers}`;
let mdoc = `${m.return_type} ${classdoc.name}.${m.name}(${argstr}) ${m.qualifiers}`;
let methodName = `${classdoc.name}.${m.name}`;
if (classdoc.name == m.name) methodName = m.name;
let mdoc = `${m.return_type} ${methodName}(${argstr}) ${m.qualifiers}`;
mdoc += " \n\n";
mdoc += m.description;
mi.documentation = mdoc;

View File

@@ -17,9 +17,7 @@ function genLink(title:string, uri:string, span=true):string {
function getProp(rawDoc:any, propname: string, action=(s :string)=>s): string {
let prop = rawDoc[propname];
if(prop && prop.length > 0)
prop = action(prop);
return prop;
return action(prop);
}
class GDScriptDocumentContentProvider implements TextDocumentContentProvider{
@@ -67,12 +65,18 @@ class GDScriptDocumentContentProvider implements TextDocumentContentProvider{
});
}
format_documentation(text: string): string {
let doc = text.replace(/\[code\]/g, "<code>").replace(/\[\/code\]/g, "</code>");
doc = doc.replace(/\[codeblock\]/g, '<pre><code class="gdscript">').replace(/\[\/codeblock]/g, "</code></pre>");
return doc;
};
genMethodDoc(mDoc:any):string {
let ret_type = getProp(mDoc, "return_type", (type:string):string =>{
if(type.length > 0)
return `${genLink(type,type)} `;
else
return "<b>void</b>";
return "void";
});
let args = "";
for(let arg of mDoc.arguments){
@@ -96,7 +100,7 @@ class GDScriptDocumentContentProvider implements TextDocumentContentProvider{
if(type.length > 0)
return `${genLink(type,type)} `;
else
return "<b>void</b>";
return "void";
});
let args = "";
for(let arg of mDoc.arguments){
@@ -274,7 +278,7 @@ class GDScriptDocumentContentProvider implements TextDocumentContentProvider{
<p>${props}</p>
<p>${methods}</p>
`;
return doc;
return this.format_documentation(doc);
}
}

View File

@@ -104,11 +104,17 @@ class GDScriptHoverProvider implements HoverProvider {
}
};
const format_documentation = (text) => {
let doc = text.replace(/\[code\]/g, "`").replace(/\[\/code\]/g, "`");
doc = doc.replace(/\[codeblock\]/g, "\n```gdscript\n").replace(/\[\/codeblock]/g, "\n```");
return doc;
};
// check from builtin
const genBuiltinTips = ()=> {
const item2MarkdStrings = (name: string,item: CompletionItem, rowDoc: any):MarkedString[] => {
let value = "";
let doc = item.documentation;
let doc = format_documentation(item.documentation);
// get class name
let classname = name;
let matchs = name.match(/[@A-z][A-z0-9]*\./);
@@ -120,8 +126,7 @@ class GDScriptHoverProvider implements HoverProvider {
const genMethodMarkDown = ():string =>{
let content = `${genLink(rowDoc.return_type, rowDoc.return_type)} `;
let matchs = name.match(/[@A-z][A-z0-9]*\./);
content += `${genLink(classname, classname)}.`;
if (rowDoc.name != classname) content += `${genLink(classname, classname)}.`;
let args = "";
for(let arg of rowDoc.arguments){
if(rowDoc.arguments.indexOf(arg)!=0)
@@ -130,7 +135,7 @@ class GDScriptHoverProvider implements HoverProvider {
if(arg.default_value && arg.default_value.length > 0)
args += `=${arg.default_value}`;
}
content += `${genLink(rowDoc.name, classname+'.'+rowDoc.name)}(${args}) ${rowDoc.qualifiers}`;
content += `${genLink(rowDoc.name, classname+'.' + rowDoc.name)}(${args}) ${rowDoc.qualifiers}`;
return content;
};
@@ -138,10 +143,10 @@ class GDScriptHoverProvider implements HoverProvider {
case CompletionItemKind.Class:
return [`Native Class ${genLink(classname, classname)}`, doc];
case CompletionItemKind.Method:
doc = item.documentation.substring(item.documentation.indexOf("\n")+1, item.documentation.length);
doc = doc.substring(doc.indexOf("\n")+1, doc.length);
return [genMethodMarkDown(), doc];
case CompletionItemKind.Interface:
doc = item.documentation.substring(item.documentation.indexOf("\n")+1, item.documentation.length);
doc = doc.substring(doc.indexOf("\n")+1, doc.length);
return ['signal ' + genMethodMarkDown(), doc];
case CompletionItemKind.Variable:
case CompletionItemKind.Property:

View File

@@ -20,8 +20,7 @@ class ToolManager {
private _context: vscode.ExtensionContext;
private _projectFile : string = "engine.cfg";
private _rootDir : string = "";
private _biuitinDocFile : string = "doc/classes.json";
private _biuitinDocFile : string = "doc/classes-2.1.json";
constructor(context: vscode.ExtensionContext) {
this._context = context;