Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
0f481700
Commit
0f481700
authored
May 28, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished PDF support for guide
added class references (current version without hyperlink)
parent
0174caf4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
196 additions
and
145 deletions
+196
-145
intro-upgrade-from-v1.md
docs/guide/intro-upgrade-from-v1.md
+2
-0
output-data-providers.md
docs/guide/output-data-providers.md
+2
-2
ApiMarkdown.php
extensions/apidoc/helpers/ApiMarkdown.php
+2
-142
ApiMarkdownLaTeX.php
extensions/apidoc/helpers/ApiMarkdownLaTeX.php
+73
-0
ApiMarkdownTrait.php
extensions/apidoc/helpers/ApiMarkdownTrait.php
+113
-0
BaseRenderer.php
extensions/apidoc/renderers/BaseRenderer.php
+2
-0
GuideRenderer.php
extensions/apidoc/templates/pdf/GuideRenderer.php
+2
-1
No files found.
docs/guide/intro-upgrade-from-v1.md
View file @
0f481700
...
@@ -5,6 +5,8 @@ There are many differences between versions 1.1 and 2.0 of Yii as the framework
...
@@ -5,6 +5,8 @@ There are many differences between versions 1.1 and 2.0 of Yii as the framework
As a result, upgrading from version 1.1 is not as trivial as upgrading between minor versions. In this guide you'll
As a result, upgrading from version 1.1 is not as trivial as upgrading between minor versions. In this guide you'll
find the major differences between the two versions.
find the major differences between the two versions.
If you have not used Yii 1.1 before, you can safely skip this section and turn directly to "
[
Getting started
](
start-installation.md
)
".
Please note that Yii 2.0 introduces more new features than are covered in this summary. It is highly recommended
Please note that Yii 2.0 introduces more new features than are covered in this summary. It is highly recommended
that you read through the whole definitive guide to learn about them all. Chances are that
that you read through the whole definitive guide to learn about them all. Chances are that
some features you previously had to develop for yourself are now part of the core code.
some features you previously had to develop for yourself are now part of the core code.
...
...
docs/guide/output-data-providers.md
View file @
0f481700
...
@@ -12,7 +12,7 @@ In Yii there are three built-in data providers: [[yii\data\ActiveDataProvider]],
...
@@ -12,7 +12,7 @@ In Yii there are three built-in data providers: [[yii\data\ActiveDataProvider]],
Active data provider
Active data provider
--------------------
--------------------
`ActiveDataProvider`
provides data by performing DB queries using
[
[
\yii\db\Query
]
] and
[
[\
yii\db\ActiveQuery
]
].
`ActiveDataProvider`
provides data by performing DB queries using
[
[
yii\db\Query
]
] and
[
[
yii\db\ActiveQuery
]
].
The following is an example of using it to provide ActiveRecord instances:
The following is an example of using it to provide ActiveRecord instances:
...
@@ -26,7 +26,7 @@ $provider = new ActiveDataProvider([
...
@@ -26,7 +26,7 @@ $provider = new ActiveDataProvider([
// get the posts in the current page
// get the posts in the current page
$posts
=
$provider
->
getModels
();
$posts
=
$provider
->
getModels
();
~~~
```
And the following example shows how to use ActiveDataProvider without ActiveRecord:
And the following example shows how to use ActiveDataProvider without ActiveRecord:
...
...
extensions/apidoc/helpers/ApiMarkdown.php
View file @
0f481700
...
@@ -23,6 +23,8 @@ use yii\helpers\Markdown;
...
@@ -23,6 +23,8 @@ use yii\helpers\Markdown;
*/
*/
class
ApiMarkdown
extends
GithubMarkdown
class
ApiMarkdown
extends
GithubMarkdown
{
{
use
ApiMarkdownTrait
;
/**
/**
* @var BaseRenderer
* @var BaseRenderer
*/
*/
...
@@ -30,58 +32,6 @@ class ApiMarkdown extends GithubMarkdown
...
@@ -30,58 +32,6 @@ class ApiMarkdown extends GithubMarkdown
protected
$context
;
protected
$context
;
public
function
prepare
()
{
parent
::
prepare
();
// add references to guide pages
$this
->
references
=
array_merge
(
$this
->
references
,
static
::
$renderer
->
guideReferences
);
}
/**
* @inheritDoc
*/
protected
function
identifyLine
(
$lines
,
$current
)
{
if
(
strncmp
(
$lines
[
$current
],
'~~~'
,
3
)
===
0
)
{
return
'fencedCode'
;
}
return
parent
::
identifyLine
(
$lines
,
$current
);
}
/**
* Consume lines for a fenced code block
*/
protected
function
consumeFencedCode
(
$lines
,
$current
)
{
// consume until ```
$block
=
[
'type'
=>
'code'
,
'content'
=>
[],
];
$line
=
rtrim
(
$lines
[
$current
]);
if
(
strncmp
(
$lines
[
$current
],
'~~~'
,
3
)
===
0
)
{
$fence
=
'~~~'
;
$language
=
'php'
;
}
else
{
$fence
=
substr
(
$line
,
0
,
$pos
=
strrpos
(
$line
,
'`'
)
+
1
);
$language
=
substr
(
$line
,
$pos
);
}
if
(
!
empty
(
$language
))
{
$block
[
'language'
]
=
$language
;
}
for
(
$i
=
$current
+
1
,
$count
=
count
(
$lines
);
$i
<
$count
;
$i
++
)
{
if
(
rtrim
(
$line
=
$lines
[
$i
])
!==
$fence
)
{
$block
[
'content'
][]
=
$line
;
}
else
{
break
;
}
}
return
[
$block
,
$i
];
}
/**
/**
* Renders a code block
* Renders a code block
*/
*/
...
@@ -125,96 +75,6 @@ class ApiMarkdown extends GithubMarkdown
...
@@ -125,96 +75,6 @@ class ApiMarkdown extends GithubMarkdown
]);
]);
}
}
protected
function
parseApiLinks
(
$text
)
{
$context
=
$this
->
context
;
if
(
preg_match
(
'/^\[\[([\w\d\\\\\(\):$]+)(\|[^\]]*)?\]\]/'
,
$text
,
$matches
))
{
$offset
=
strlen
(
$matches
[
0
]);
$object
=
$matches
[
1
];
$title
=
(
empty
(
$matches
[
2
])
||
$matches
[
2
]
==
'|'
)
?
null
:
substr
(
$matches
[
2
],
1
);
if
((
$pos
=
strpos
(
$object
,
'::'
))
!==
false
)
{
$typeName
=
substr
(
$object
,
0
,
$pos
);
$subjectName
=
substr
(
$object
,
$pos
+
2
);
if
(
$context
!==
null
)
{
// Collection resolves relative types
$typeName
=
(
new
Collection
([
$typeName
],
$context
->
phpDocContext
))
->
__toString
();
}
$type
=
static
::
$renderer
->
apiContext
->
getType
(
$typeName
);
if
(
$type
===
null
)
{
static
::
$renderer
->
apiContext
->
errors
[]
=
[
'file'
=>
(
$context
!==
null
)
?
$context
->
sourceFile
:
null
,
'message'
=>
'broken link to '
.
$typeName
.
'::'
.
$subjectName
.
((
$context
!==
null
)
?
' in '
.
$context
->
name
:
''
),
];
return
[
'<span style="background: #f00;">'
.
$typeName
.
'::'
.
$subjectName
.
'</span>'
,
$offset
];
}
else
{
if
((
$subject
=
$type
->
findSubject
(
$subjectName
))
!==
null
)
{
if
(
$title
===
null
)
{
$title
=
$type
->
name
.
'::'
.
$subject
->
name
;
if
(
$subject
instanceof
MethodDoc
)
{
$title
.=
'()'
;
}
}
return
[
static
::
$renderer
->
createSubjectLink
(
$subject
,
$title
),
$offset
];
}
else
{
static
::
$renderer
->
apiContext
->
errors
[]
=
[
'file'
=>
(
$context
!==
null
)
?
$context
->
sourceFile
:
null
,
'message'
=>
'broken link to '
.
$type
->
name
.
'::'
.
$subjectName
.
((
$context
!==
null
)
?
' in '
.
$context
->
name
:
''
),
];
return
[
'<span style="background: #ff0;">'
.
$type
->
name
.
'</span><span style="background: #f00;">::'
.
$subjectName
.
'</span>'
,
$offset
];
}
}
}
elseif
(
$context
!==
null
&&
(
$subject
=
$context
->
findSubject
(
$object
))
!==
null
)
{
return
[
static
::
$renderer
->
createSubjectLink
(
$subject
,
$title
),
$offset
];
}
if
(
$context
!==
null
)
{
// Collection resolves relative types
$object
=
(
new
Collection
([
$object
],
$context
->
phpDocContext
))
->
__toString
();
}
if
((
$type
=
static
::
$renderer
->
apiContext
->
getType
(
$object
))
!==
null
)
{
return
[
static
::
$renderer
->
createTypeLink
(
$type
,
null
,
$title
),
$offset
];
}
elseif
(
strpos
(
$typeLink
=
static
::
$renderer
->
createTypeLink
(
$object
,
null
,
$title
),
'<a href'
)
!==
false
)
{
return
[
$typeLink
,
$offset
];
}
static
::
$renderer
->
apiContext
->
errors
[]
=
[
'file'
=>
(
$context
!==
null
)
?
$context
->
sourceFile
:
null
,
'message'
=>
'broken link to '
.
$object
.
((
$context
!==
null
)
?
' in '
.
$context
->
name
:
''
),
];
return
[
'<span style="background: #f00;">'
.
$object
.
'</span>'
,
$offset
];
}
return
[
'[['
,
2
];
}
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
...
...
extensions/apidoc/helpers/ApiMarkdownLaTeX.php
0 → 100644
View file @
0f481700
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\apidoc\helpers
;
use
cebe\markdown\latex\GithubMarkdown
;
use
yii\apidoc\models\TypeDoc
;
use
yii\apidoc\renderers\BaseRenderer
;
use
yii\helpers\Markdown
;
/**
* A Markdown helper with support for class reference links.
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class
ApiMarkdownLaTeX
extends
GithubMarkdown
{
use
ApiMarkdownTrait
;
/**
* @var BaseRenderer
*/
public
static
$renderer
;
protected
$context
;
protected
function
inlineMarkers
()
{
return
array_merge
(
parent
::
inlineMarkers
(),
[
'[['
=>
'parseApiLinksLatex'
,
]);
}
protected
function
parseApiLinksLatex
(
$text
)
{
list
(
$html
,
$offset
)
=
$this
->
parseApiLinks
(
$text
);
$latex
=
'\texttt{'
.
str_replace
([
'\\textbackslash'
,
'::'
],
[
'\allowbreak{}\\textbackslash'
,
'\allowbreak{}::\allowbreak{}'
],
$this
->
escapeLatex
(
strip_tags
(
$html
)))
.
'}'
;
return
[
$latex
,
$offset
];
}
/**
* Converts markdown into HTML
*
* @param string $content
* @param TypeDoc $context
* @param boolean $paragraph
* @return string
*/
public
static
function
process
(
$content
,
$context
=
null
,
$paragraph
=
false
)
{
if
(
!
isset
(
Markdown
::
$flavors
[
'api-latex'
]))
{
Markdown
::
$flavors
[
'api-latex'
]
=
new
static
;
}
if
(
is_string
(
$context
))
{
$context
=
static
::
$renderer
->
apiContext
->
getType
(
$context
);
}
Markdown
::
$flavors
[
'api-latex'
]
->
context
=
$context
;
if
(
$paragraph
)
{
return
Markdown
::
processParagraph
(
$content
,
'api-latex'
);
}
else
{
return
Markdown
::
process
(
$content
,
'api-latex'
);
}
}
}
extensions/apidoc/helpers/ApiMarkdownTrait.php
0 → 100644
View file @
0f481700
<?php
/**
* Created by PhpStorm.
* User: cebe
* Date: 28.05.14
* Time: 15:30
*/
namespace
yii\apidoc\helpers
;
use
cebe\markdown\GithubMarkdown
;
use
phpDocumentor\Reflection\DocBlock\Type\Collection
;
use
yii\apidoc\models\MethodDoc
;
use
yii\apidoc\models\TypeDoc
;
/**
* Class ApiMarkdownTrait
*
* @property TypeDoc $context
*/
trait
ApiMarkdownTrait
{
protected
function
parseApiLinks
(
$text
)
{
$context
=
$this
->
context
;
if
(
preg_match
(
'/^\[\[([\w\d\\\\\(\):$]+)(\|[^\]]*)?\]\]/'
,
$text
,
$matches
))
{
$offset
=
strlen
(
$matches
[
0
]);
$object
=
$matches
[
1
];
$title
=
(
empty
(
$matches
[
2
])
||
$matches
[
2
]
==
'|'
)
?
null
:
substr
(
$matches
[
2
],
1
);
if
((
$pos
=
strpos
(
$object
,
'::'
))
!==
false
)
{
$typeName
=
substr
(
$object
,
0
,
$pos
);
$subjectName
=
substr
(
$object
,
$pos
+
2
);
if
(
$context
!==
null
)
{
// Collection resolves relative types
$typeName
=
(
new
Collection
([
$typeName
],
$context
->
phpDocContext
))
->
__toString
();
}
$type
=
static
::
$renderer
->
apiContext
->
getType
(
$typeName
);
if
(
$type
===
null
)
{
static
::
$renderer
->
apiContext
->
errors
[]
=
[
'file'
=>
(
$context
!==
null
)
?
$context
->
sourceFile
:
null
,
'message'
=>
'broken link to '
.
$typeName
.
'::'
.
$subjectName
.
((
$context
!==
null
)
?
' in '
.
$context
->
name
:
''
),
];
return
[
'<span style="background: #f00;">'
.
$typeName
.
'::'
.
$subjectName
.
'</span>'
,
$offset
];
}
else
{
if
((
$subject
=
$type
->
findSubject
(
$subjectName
))
!==
null
)
{
if
(
$title
===
null
)
{
$title
=
$type
->
name
.
'::'
.
$subject
->
name
;
if
(
$subject
instanceof
MethodDoc
)
{
$title
.=
'()'
;
}
}
return
[
static
::
$renderer
->
createSubjectLink
(
$subject
,
$title
),
$offset
];
}
else
{
static
::
$renderer
->
apiContext
->
errors
[]
=
[
'file'
=>
(
$context
!==
null
)
?
$context
->
sourceFile
:
null
,
'message'
=>
'broken link to '
.
$type
->
name
.
'::'
.
$subjectName
.
((
$context
!==
null
)
?
' in '
.
$context
->
name
:
''
),
];
return
[
'<span style="background: #ff0;">'
.
$type
->
name
.
'</span><span style="background: #f00;">::'
.
$subjectName
.
'</span>'
,
$offset
];
}
}
}
elseif
(
$context
!==
null
&&
(
$subject
=
$context
->
findSubject
(
$object
))
!==
null
)
{
return
[
static
::
$renderer
->
createSubjectLink
(
$subject
,
$title
),
$offset
];
}
if
(
$context
!==
null
)
{
// Collection resolves relative types
$object
=
(
new
Collection
([
$object
],
$context
->
phpDocContext
))
->
__toString
();
}
if
((
$type
=
static
::
$renderer
->
apiContext
->
getType
(
$object
))
!==
null
)
{
return
[
static
::
$renderer
->
createTypeLink
(
$type
,
null
,
$title
),
$offset
];
}
elseif
(
strpos
(
$typeLink
=
static
::
$renderer
->
createTypeLink
(
$object
,
null
,
$title
),
'<a href'
)
!==
false
)
{
return
[
$typeLink
,
$offset
];
}
static
::
$renderer
->
apiContext
->
errors
[]
=
[
'file'
=>
(
$context
!==
null
)
?
$context
->
sourceFile
:
null
,
'message'
=>
'broken link to '
.
$object
.
((
$context
!==
null
)
?
' in '
.
$context
->
name
:
''
),
];
return
[
'<span style="background: #f00;">'
.
$object
.
'</span>'
,
$offset
];
}
return
[
'[['
,
2
];
}
}
\ No newline at end of file
extensions/apidoc/renderers/BaseRenderer.php
View file @
0f481700
...
@@ -9,6 +9,7 @@ namespace yii\apidoc\renderers;
...
@@ -9,6 +9,7 @@ namespace yii\apidoc\renderers;
use
Yii
;
use
Yii
;
use
yii\apidoc\helpers\ApiMarkdown
;
use
yii\apidoc\helpers\ApiMarkdown
;
use
yii\apidoc\helpers\ApiMarkdownLaTeX
;
use
yii\apidoc\models\BaseDoc
;
use
yii\apidoc\models\BaseDoc
;
use
yii\apidoc\models\ClassDoc
;
use
yii\apidoc\models\ClassDoc
;
use
yii\apidoc\models\ConstDoc
;
use
yii\apidoc\models\ConstDoc
;
...
@@ -48,6 +49,7 @@ abstract class BaseRenderer extends Component
...
@@ -48,6 +49,7 @@ abstract class BaseRenderer extends Component
public
function
init
()
public
function
init
()
{
{
ApiMarkdown
::
$renderer
=
$this
;
ApiMarkdown
::
$renderer
=
$this
;
ApiMarkdownLaTeX
::
$renderer
=
$this
;
}
}
/**
/**
...
...
extensions/apidoc/templates/pdf/GuideRenderer.php
View file @
0f481700
...
@@ -10,6 +10,7 @@ namespace yii\apidoc\templates\pdf;
...
@@ -10,6 +10,7 @@ namespace yii\apidoc\templates\pdf;
use
cebe\markdown\latex\GithubMarkdown
;
use
cebe\markdown\latex\GithubMarkdown
;
use
Yii
;
use
Yii
;
use
yii\apidoc\helpers\ApiIndexer
;
use
yii\apidoc\helpers\ApiIndexer
;
use
yii\apidoc\helpers\ApiMarkdownLaTeX
;
use
yii\apidoc\helpers\IndexFileAnalyzer
;
use
yii\apidoc\helpers\IndexFileAnalyzer
;
use
yii\helpers\Console
;
use
yii\helpers\Console
;
use
yii\helpers\FileHelper
;
use
yii\helpers\FileHelper
;
...
@@ -62,7 +63,7 @@ class GuideRenderer extends \yii\apidoc\templates\html\GuideRenderer
...
@@ -62,7 +63,7 @@ class GuideRenderer extends \yii\apidoc\templates\html\GuideRenderer
// }
// }
}
}
$md
=
new
GithubMarkdown
();
$md
=
new
ApiMarkdownLaTeX
();
$output
=
''
;
$output
=
''
;
foreach
(
$chapters
as
$chapter
)
{
foreach
(
$chapters
as
$chapter
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment