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
Show 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
...
@@ -81,7 +81,7 @@ class ApiMarkdown extends GithubMarkdown
{
{
$content
=
$this
->
parseInline
(
$block
[
'content'
]);
$content
=
$this
->
parseInline
(
$block
[
'content'
]);
$hash
=
Inflector
::
slug
(
strip_tags
(
$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'
];
$tag
=
'h'
.
$block
[
'level'
];
return
"<
$tag
>
$content
$hashLink
</
$tag
>"
;
return
"<
$tag
>
$content
$hashLink
</
$tag
>"
;
...
...
extensions/apidoc/renderers/GuideRenderer.php
View file @
75b1f481
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
namespace
yii\apidoc\renderers
;
namespace
yii\apidoc\renderers
;
use
Yii
;
use
Yii
;
use
yii\apidoc\helpers\IndexFileAnalyzer
;
/**
/**
* Base class for all Guide documentation renderers
* Base class for all Guide documentation renderers
...
@@ -25,4 +26,24 @@ abstract class GuideRenderer extends BaseRenderer
...
@@ -25,4 +26,24 @@ abstract class GuideRenderer extends BaseRenderer
*/
*/
abstract
public
function
render
(
$files
,
$targetDir
);
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%; }
...
@@ -110,6 +110,35 @@ table.summary-table .col-defined { width: 15%; }
text-decoration
:
none
;
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
{
#search-resultbox
{
position
:
fixed
;
position
:
fixed
;
...
...
extensions/apidoc/templates/bootstrap/layouts/guide.php
View file @
75b1f481
...
@@ -5,6 +5,7 @@ use yii\apidoc\templates\bootstrap\SideNavWidget;
...
@@ -5,6 +5,7 @@ use yii\apidoc\templates\bootstrap\SideNavWidget;
/**
/**
* @var yii\web\View $this
* @var yii\web\View $this
* @var string $content
* @var string $content
* @var array $chapters
*/
*/
$this
->
beginContent
(
'@yii/apidoc/templates/bootstrap/layouts/main.php'
);
?>
$this
->
beginContent
(
'@yii/apidoc/templates/bootstrap/layouts/main.php'
);
?>
...
@@ -12,23 +13,20 @@ $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=
"row"
>
<div
class=
"col-md-2"
>
<div
class=
"col-md-2"
>
<?php
<?php
asort
(
$headlines
);
$nav
=
[];
$nav
=
[];
foreach
(
$headlines
as
$file
=>
$headline
)
{
foreach
(
$chapters
as
$chapter
)
{
if
(
basename
(
$file
)
==
'README.md'
)
{
$items
=
[];
$nav
[]
=
[
foreach
(
$chapter
[
'content'
]
as
$chContent
)
{
'label'
=>
$headline
,
$items
[]
=
[
'url'
=>
$this
->
context
->
generateGuideUrl
(
$file
),
'label'
=>
$chContent
[
'headline'
],
'active'
=>
isset
(
$currentFile
)
&&
(
$file
==
$currentFile
),
'url'
=>
$this
->
context
->
generateGuideUrl
(
$chContent
[
'file'
]),
'active'
=>
isset
(
$currentFile
)
&&
(
$chContent
[
'file'
]
==
basename
(
$currentFile
)),
];
];
unset
(
$headlines
[
$file
]);
}
}
}
foreach
(
$headlines
as
$file
=>
$headline
)
{
$nav
[]
=
[
$nav
[]
=
[
'label'
=>
$
headline
,
'label'
=>
$
chapter
[
'headline'
]
,
'url'
=>
$this
->
context
->
generateGuideUrl
(
$file
),
//
'url' => $this->context->generateGuideUrl($file),
'
active'
=>
isset
(
$currentFile
)
&&
(
$file
==
$currentFile
)
,
'
items'
=>
$items
,
];
];
}
?>
}
?>
<?=
SideNavWidget
::
widget
([
<?=
SideNavWidget
::
widget
([
...
@@ -39,6 +37,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
...
@@ -39,6 +37,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
</div>
</div>
<div
class=
"col-md-9 guide-content"
role=
"main"
>
<div
class=
"col-md-9 guide-content"
role=
"main"
>
<?=
$content
?>
<?=
$content
?>
<div
class=
"toplink"
><a
href=
"#"
class=
"h1"
title=
"go to top"
><span
class=
"glyphicon glyphicon-arrow-up"
></a></div>
</div>
</div>
</div>
</div>
...
...
extensions/apidoc/templates/html/GuideRenderer.php
View file @
75b1f481
...
@@ -78,17 +78,12 @@ abstract class GuideRenderer extends BaseGuideRenderer
...
@@ -78,17 +78,12 @@ abstract class GuideRenderer extends BaseGuideRenderer
}
}
$done
=
0
;
$done
=
0
;
$fileData
=
[];
$fileData
=
[];
$
headlines
=
[]
;
$
chapters
=
$this
->
loadGuideStructure
(
$files
)
;
foreach
(
$files
as
$file
)
{
foreach
(
$files
as
$file
)
{
$fileData
[
$file
]
=
file_get_contents
(
$file
);
$fileData
[
$file
]
=
file_get_contents
(
$file
);
if
(
basename
(
$file
)
==
'README.md'
)
{
if
(
basename
(
$file
)
==
'README.md'
)
{
continue
;
// to not add index file to nav
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
)
{
foreach
(
$fileData
as
$file
=>
$content
)
{
...
@@ -96,7 +91,7 @@ abstract class GuideRenderer extends BaseGuideRenderer
...
@@ -96,7 +91,7 @@ abstract class GuideRenderer extends BaseGuideRenderer
$output
=
$this
->
fixMarkdownLinks
(
$output
);
$output
=
$this
->
fixMarkdownLinks
(
$output
);
if
(
$this
->
layout
!==
false
)
{
if
(
$this
->
layout
!==
false
)
{
$params
=
[
$params
=
[
'
headlines'
=>
$headline
s
,
'
chapters'
=>
$chapter
s
,
'currentFile'
=>
$file
,
'currentFile'
=>
$file
,
'content'
=>
$output
,
'content'
=>
$output
,
];
];
...
...
extensions/apidoc/templates/pdf/GuideRenderer.php
View file @
75b1f481
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
namespace
yii\apidoc\templates\pdf
;
namespace
yii\apidoc\templates\pdf
;
use
cebe\markdown\latex\GithubMarkdown
;
use
Yii
;
use
Yii
;
use
yii\apidoc\helpers\ApiMarkdownLaTeX
;
use
yii\apidoc\helpers\ApiMarkdownLaTeX
;
use
yii\apidoc\helpers\IndexFileAnalyzer
;
use
yii\apidoc\helpers\IndexFileAnalyzer
;
...
@@ -43,13 +42,8 @@ class GuideRenderer extends \yii\apidoc\templates\html\GuideRenderer
...
@@ -43,13 +42,8 @@ class GuideRenderer extends \yii\apidoc\templates\html\GuideRenderer
}
}
$done
=
0
;
$done
=
0
;
$fileData
=
[];
$fileData
=
[];
$chapters
=
[]
;
$chapters
=
$this
->
loadGuideStructure
(
$files
)
;
foreach
(
$files
as
$file
)
{
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'
)
{
if
(
basename
(
$file
)
==
'tutorial-i18n.md'
)
{
continue
;
// TODO avoid i18n tut because of non displayable characters right now. need to fix it.
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