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
75b1f481
Commit
75b1f481
authored
Jun 10, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved HTML guide navigation
parent
713f73e6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
28 deletions
+66
-28
ApiMarkdown.php
extensions/apidoc/helpers/ApiMarkdown.php
+1
-1
GuideRenderer.php
extensions/apidoc/renderers/GuideRenderer.php
+21
-0
style.css
extensions/apidoc/templates/bootstrap/assets/css/style.css
+29
-0
guide.php
extensions/apidoc/templates/bootstrap/layouts/guide.php
+12
-13
GuideRenderer.php
extensions/apidoc/templates/html/GuideRenderer.php
+2
-7
GuideRenderer.php
extensions/apidoc/templates/pdf/GuideRenderer.php
+1
-7
No files found.
extensions/apidoc/helpers/ApiMarkdown.php
View file @
75b1f481
...
...
@@ -81,7 +81,7 @@ class ApiMarkdown extends GithubMarkdown
{
$content
=
$this
->
parseInline
(
$block
[
'content'
]);
$hash
=
Inflector
::
slug
(
strip_tags
(
$content
));
$hashLink
=
"<a href=
\"
#
$hash
\"
name=
\"
$hash
\"
>¶</a>"
;
$hashLink
=
"<a href=
\"
#
$hash
\"
name=
\"
$hash
\"
class=
\"
hashlink
\"
>¶</a>"
;
$tag
=
'h'
.
$block
[
'level'
];
return
"<
$tag
>
$content
$hashLink
</
$tag
>"
;
...
...
extensions/apidoc/renderers/GuideRenderer.php
View file @
75b1f481
...
...
@@ -8,6 +8,7 @@
namespace
yii\apidoc\renderers
;
use
Yii
;
use
yii\apidoc\helpers\IndexFileAnalyzer
;
/**
* Base class for all Guide documentation renderers
...
...
@@ -25,4 +26,24 @@ abstract class GuideRenderer extends BaseRenderer
*/
abstract
public
function
render
(
$files
,
$targetDir
);
protected
function
loadGuideStructure
(
$files
)
{
$chapters
=
[];
foreach
(
$files
as
$file
)
{
$contents
=
file_get_contents
(
$file
);
if
(
basename
(
$file
)
==
'README.md'
)
{
$indexAnalyzer
=
new
IndexFileAnalyzer
();
$chapters
=
$indexAnalyzer
->
analyze
(
$contents
);
break
;
}
if
(
preg_match
(
"/^(.*)
\n
=+/"
,
$contents
,
$matches
))
{
$headlines
[
$file
]
=
$matches
[
1
];
}
else
{
$headlines
[
$file
]
=
basename
(
$file
);
}
}
return
$chapters
;
}
}
extensions/apidoc/templates/bootstrap/assets/css/style.css
View file @
75b1f481
...
...
@@ -110,6 +110,35 @@ table.summary-table .col-defined { width: 15%; }
text-decoration
:
none
;
}
.hashlink
{
display
:
none
;
}
h1
:hover
.hashlink
,
h2
:hover
.hashlink
,
h3
:hover
.hashlink
,
h4
:hover
.hashlink
,
h5
:hover
.hashlink
{
display
:
inline
;
}
.toplink
{
position
:
fixed
;
bottom
:
50px
;
right
:
50px
;
padding
:
5px
8px
0
5px
;
border
:
solid
1px
#ddd
;
border-radius
:
5px
;
background
:
#fff
;
}
.toplink
a
{
color
:
#bbb
;
text-decoration
:
none
;
}
.toplink
a
:hover
{
color
:
#999
;
text-decoration
:
none
;
}
#search-resultbox
{
position
:
fixed
;
...
...
extensions/apidoc/templates/bootstrap/layouts/guide.php
View file @
75b1f481
...
...
@@ -5,6 +5,7 @@ use yii\apidoc\templates\bootstrap\SideNavWidget;
/**
* @var yii\web\View $this
* @var string $content
* @var array $chapters
*/
$this
->
beginContent
(
'@yii/apidoc/templates/bootstrap/layouts/main.php'
);
?>
...
...
@@ -12,23 +13,20 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
<div
class=
"row"
>
<div
class=
"col-md-2"
>
<?php
asort
(
$headlines
);
$nav
=
[];
foreach
(
$headlines
as
$file
=>
$headline
)
{
if
(
basename
(
$file
)
==
'README.md'
)
{
$nav
[]
=
[
'label'
=>
$headline
,
'url'
=>
$this
->
context
->
generateGuideUrl
(
$file
),
'active'
=>
isset
(
$currentFile
)
&&
(
$file
==
$currentFile
),
foreach
(
$chapters
as
$chapter
)
{
$items
=
[];
foreach
(
$chapter
[
'content'
]
as
$chContent
)
{
$items
[]
=
[
'label'
=>
$chContent
[
'headline'
],
'url'
=>
$this
->
context
->
generateGuideUrl
(
$chContent
[
'file'
]),
'active'
=>
isset
(
$currentFile
)
&&
(
$chContent
[
'file'
]
==
basename
(
$currentFile
)),
];
unset
(
$headlines
[
$file
]);
}
}
foreach
(
$headlines
as
$file
=>
$headline
)
{
$nav
[]
=
[
'label'
=>
$
headline
,
'url'
=>
$this
->
context
->
generateGuideUrl
(
$file
),
'
active'
=>
isset
(
$currentFile
)
&&
(
$file
==
$currentFile
)
,
'label'
=>
$
chapter
[
'headline'
]
,
//
'url' => $this->context->generateGuideUrl($file),
'
items'
=>
$items
,
];
}
?>
<?=
SideNavWidget
::
widget
([
...
...
@@ -39,6 +37,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
</div>
<div
class=
"col-md-9 guide-content"
role=
"main"
>
<?=
$content
?>
<div
class=
"toplink"
><a
href=
"#"
class=
"h1"
title=
"go to top"
><span
class=
"glyphicon glyphicon-arrow-up"
></a></div>
</div>
</div>
...
...
extensions/apidoc/templates/html/GuideRenderer.php
View file @
75b1f481
...
...
@@ -78,17 +78,12 @@ abstract class GuideRenderer extends BaseGuideRenderer
}
$done
=
0
;
$fileData
=
[];
$
headlines
=
[]
;
$
chapters
=
$this
->
loadGuideStructure
(
$files
)
;
foreach
(
$files
as
$file
)
{
$fileData
[
$file
]
=
file_get_contents
(
$file
);
if
(
basename
(
$file
)
==
'README.md'
)
{
continue
;
// to not add index file to nav
}
if
(
preg_match
(
"/^(.*)
\n
=+/"
,
$fileData
[
$file
],
$matches
))
{
$headlines
[
$file
]
=
$matches
[
1
];
}
else
{
$headlines
[
$file
]
=
basename
(
$file
);
}
}
foreach
(
$fileData
as
$file
=>
$content
)
{
...
...
@@ -96,7 +91,7 @@ abstract class GuideRenderer extends BaseGuideRenderer
$output
=
$this
->
fixMarkdownLinks
(
$output
);
if
(
$this
->
layout
!==
false
)
{
$params
=
[
'
headlines'
=>
$headline
s
,
'
chapters'
=>
$chapter
s
,
'currentFile'
=>
$file
,
'content'
=>
$output
,
];
...
...
extensions/apidoc/templates/pdf/GuideRenderer.php
View file @
75b1f481
...
...
@@ -7,7 +7,6 @@
namespace
yii\apidoc\templates\pdf
;
use
cebe\markdown\latex\GithubMarkdown
;
use
Yii
;
use
yii\apidoc\helpers\ApiMarkdownLaTeX
;
use
yii\apidoc\helpers\IndexFileAnalyzer
;
...
...
@@ -43,13 +42,8 @@ class GuideRenderer extends \yii\apidoc\templates\html\GuideRenderer
}
$done
=
0
;
$fileData
=
[];
$chapters
=
[]
;
$chapters
=
$this
->
loadGuideStructure
(
$files
)
;
foreach
(
$files
as
$file
)
{
if
(
basename
(
$file
)
==
'README.md'
)
{
$indexAnalyzer
=
new
IndexFileAnalyzer
();
$chapters
=
$indexAnalyzer
->
analyze
(
file_get_contents
(
$file
));
continue
;
// to not add index file to nav
}
if
(
basename
(
$file
)
==
'tutorial-i18n.md'
)
{
continue
;
// TODO avoid i18n tut because of non displayable characters right now. need to fix it.
}
...
...
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