File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Yii Framework 2 apidoc extension Change Log
88- Enh #38 : Fixed display of default values given as octal or hex notation (hiqsol)
99- Enh: Display TOC only if there is more than one headline (cebe)
1010- Enh: Extracted markdown code highlighting to a trait ` MarkdownHighlightTrait ` (cebe)
11+ - Enh: Added "type" attribute to JSON renderer to keep information about whether an entry is a class, interface or trait (cebe)
1112
1213
13142.1.0 November 22, 2016
Original file line number Diff line number Diff line change 77
88namespace yii \apidoc \templates \json ;
99
10+ use yii \apidoc \models \ClassDoc ;
1011use yii \apidoc \models \Context ;
12+ use yii \apidoc \models \InterfaceDoc ;
13+ use yii \apidoc \models \TraitDoc ;
1114use yii \apidoc \renderers \ApiRenderer as BaseApiRenderer ;
1215use yii \base \ViewContextInterface ;
1316use Yii ;
@@ -29,6 +32,16 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
2932 public function render ($ context , $ targetDir )
3033 {
3134 $ types = array_merge ($ context ->classes , $ context ->interfaces , $ context ->traits );
35+ foreach ($ types as $ name => $ type ) {
36+ $ types [$ name ] = (array ) $ type ;
37+ if ($ type instanceof ClassDoc) {
38+ $ types [$ name ]['type ' ] = 'class ' ;
39+ } elseif ($ type instanceof InterfaceDoc) {
40+ $ types [$ name ]['type ' ] = 'interface ' ;
41+ } elseif ($ type instanceof TraitDoc) {
42+ $ types [$ name ]['type ' ] = 'trait ' ;
43+ }
44+ }
3245 file_put_contents ($ targetDir . '/types.json ' , json_encode ($ types , JSON_PRETTY_PRINT ));
3346 }
3447
You can’t perform that action at this time.
0 commit comments