Skip to content

Commit

Permalink
添加对 D 语言的支持
Browse files Browse the repository at this point in the history
update #11
  • Loading branch information
caixw committed Jul 12, 2016
1 parent 81a5d7d commit 2dadab1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
// 版本号
//
// 版本号按照 http://semver.org 中的规则
Version = "2.16.7+20160712"
Version = "2.16.8+20160712"

// 程序的正式名称
Name = "apidoc"
Expand Down
2 changes: 2 additions & 0 deletions input/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestParse(t *testing.T) {
a := assert.New(t)

testParse(a, "c++")
testParse(a, "d")
testParse(a, "go")
testParse(a, "java")
testParse(a, "javascript")
Expand Down Expand Up @@ -62,6 +63,7 @@ func TestParseFile(t *testing.T) {
a := assert.New(t)

testParseFile(a, "c++", "./testdata/c++/test1.c")
testParseFile(a, "d", "./testdata/d/test1.d")
testParseFile(a, "go", "./testdata/go/test1.go")
testParseFile(a, "java", "./testdata/java/test1.java")
testParseFile(a, "javascript", "./testdata/javascript/test1.js")
Expand Down
4 changes: 4 additions & 0 deletions input/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var langs = map[string][]blocker{
// c/c++
"c++": cStyle,

// d
"d": cStyle,

// golang
"go": []blocker{
&block{Type: blockTypeString, Begin: `"`, End: `"`, Escape: `\`},
Expand Down Expand Up @@ -111,6 +114,7 @@ var cStyle = []blocker{
var langExts = map[string][]string{
"c#": []string{".cs"},
"c++": []string{".h", ".c", ".cpp", ".cxx", "hpp"},
"d": []string{".d"},
"go": []string{".go"},
"java": []string{".java"},
"javascript": []string{".js"},
Expand Down
12 changes: 12 additions & 0 deletions input/testdata/d/doc.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2016 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.


// @apidoc title of api
// @apiVersion 2.9
// @apiBaseURL https://api.caixw.io
// @apiLicense MIT https://opensources.org/licenses/MIT
// @apiContent
// line1
// line2
48 changes: 48 additions & 0 deletions input/testdata/d/test1.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2016 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

import std.stdio;

// @api POST /users/login 登录
// @apiGroup users
//
// @apiRequest json
// @apiParam username string 登录账号
// @apiParam password string 密码
//
// @apiSuccess 201 OK
// @apiParam expires int 过期时间
// @apiParam token string 凭证
// @apiExample json
// {
// "expires": 11111111,
// "token": "adl;kfqwer;q;afd"
// }
//
// @apiError 401 账号或密码错误
void login(http::ResponseWriter w, http::Request& r) {
writeln("/*********", "login");
// TODO
}

/*
* @api DELETE /users/login 注销登录
* @apiGroup users
*
* @apiRequest json
* @apiHeader Authorization xxxx
*
* @apiSuccess 201 OK
* @apiParam expires int 过期时间
* @apiParam token string 凭证
* @apiExample json
* {
* "expires": 11111111,
* "token": "adl;kfqwer;q;afd"
* }
*/
void logout(http::ResponseWriter w, http::Request& r) {
writeln("logout", "*******/");
// TODO
}

0 comments on commit 2dadab1

Please sign in to comment.