Skip to content

Commit

Permalink
Merge commit 'b8682e7ff092939f876fa1bcaf7505fea7c5b3cf'
Browse files Browse the repository at this point in the history
Conflicts:
	components/BaseController.php
	composer.json
	templates/online/ApiRenderer.php
  • Loading branch information
bisubus committed May 14, 2015
2 parents e49d05f + b8682e7 commit 8c91c00
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 19 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Yii Framework 2 apidoc extension Change Log
2.0.4 under development
-----------------------

- no changes in this release.
- Bug #3: Interface documentation did not show inheritance (cebe)
- Enh: Added ability to set pageTitle from command line (unclead)


2.0.3 March 01, 2015
Expand Down
4 changes: 4 additions & 0 deletions commands/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public function actionIndex(array $sourceDirs, $targetDir)
$renderer->apiUrl = './';
$renderer->guidePrefix = $this->guidePrefix;

if ($this->pageTitle !== null) {
$renderer->pageTitle = $this->pageTitle;
}

// setup reference to guide
if ($this->guide !== null) {
$renderer->guideUrl = $guideUrl = $this->guide;
Expand Down
3 changes: 3 additions & 0 deletions commands/GuideController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function actionIndex(array $sourceDirs, $targetDir)
return 1;
}

if ($this->pageTitle !== null) {
$renderer->pageTitle = $this->pageTitle;
}
if ($renderer->guideUrl === null) {
$renderer->guideUrl = './';
}
Expand Down
8 changes: 6 additions & 2 deletions components/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ abstract class BaseController extends Controller
* @var string|array files to exclude.
*/
public $exclude;
/**
* @var string page title
*/
public $pageTitle;
/**
* @var boolean force overwrite
*/
public $overwrite;


/**
* Checks that target directory is valid. Asks questions in tricky cases.
* @param string $target
Expand Down Expand Up @@ -160,6 +164,6 @@ abstract protected function findRenderer($template);
*/
public function options($actionID)
{
return array_merge(parent::options($actionID), ['template', 'exclude', 'overwrite']);
return array_merge(parent::options($actionID), ['template', 'exclude', 'pageTitle', 'overwrite']);
}
}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Aapidoc",
"issues": "https://github.com/yiisoft/yii2-apidoc/issues",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
"source": "https://github.com/yiisoft/yii2-apidoc"
},
"authors": [
{
Expand All @@ -19,7 +19,7 @@
],
"minimum-stability": "dev",
"require": {
"yiisoft/yii2-dev": "*",
"yiisoft/yii2-dev": ">=2.0.4",
"yiisoft/yii2-bootstrap": "*",
"bower-asset/jquery": "1.*@stable",
"twbs/bootstrap": "*",
Expand Down
23 changes: 23 additions & 0 deletions models/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public function updateReferences()
}
}
}
foreach ($this->interfaces as $interface) {
foreach ($interface->parentInterfaces as $pInterface) {
$this->interfaces[$pInterface]->implementedBy[] = $interface->name;
}
}
// inherit docs
foreach ($this->classes as $class) {
$this->inheritDocs($class);
Expand All @@ -129,6 +134,9 @@ public function updateReferences()
foreach ($this->classes as $class) {
$this->updateSubclassInheritance($class);
}
foreach ($this->interfaces as $interface) {
$this->updateSubInterfaceInheritance($interface);
}
// add properties from getters and setters
foreach ($this->classes as $class) {
$this->handlePropertyFeature($class);
Expand Down Expand Up @@ -167,6 +175,21 @@ protected function updateSubclassInheritance($class)
}
}

/**
* Add methods to subinterfaces
* @param InterfaceDoc $class
*/
protected function updateSubInterfaceInheritance($interface)
{
foreach ($interface->implementedBy as $subInterface) {
if (isset($this->interfaces[$subInterface])) {
$subInterface = $this->interfaces[$subInterface];
$subInterface->methods = array_merge($interface->methods, $subInterface->methods);
$this->updateSubInterfaceInheritance($subInterface);
}
}
}

/**
* Inhertit docsblocks using `@inheritDoc` tag.
* @param ClassDoc $class
Expand Down
5 changes: 5 additions & 0 deletions renderers/BaseRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ abstract class BaseRenderer extends Component

public $guidePrefix = 'guide-';
public $apiUrl;
/**
* @var string string to use as the title of the generated page.
*/
public $pageTitle;

/**
* @var Context the [[Context]] currently being rendered.
*/
Expand Down
15 changes: 9 additions & 6 deletions templates/bootstrap/ApiRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,28 @@ public function getSourceUrl($type, $line = null)
$type = $this->apiContext->getType($type);
}

$baseUrl = 'https://github.com/yiisoft/yii2/blob/master';
switch ($this->getTypeCategory($type)) {
case 'yii':
$baseUrl = 'https://github.com/yiisoft/yii2/blob/master';
if ($type->name == 'Yii') {
$url = '/framework/Yii.php';
$url = "$baseUrl/framework/Yii.php";
} else {
$url = '/framework/' . str_replace('\\', '/', substr($type->name, 4)) . '.php';
$url = "$baseUrl/framework/" . str_replace('\\', '/', substr($type->name, 4)) . '.php';
}
break;
case 'app':
return null;
default:
$url = '/extensions/' . str_replace('\\', '/', substr($type->name, 4)) . '.php';
$parts = explode('\\', substr($type->name, 4));
$ext = $parts[0];
unset($parts[0]);
$url = "https://github.com/yiisoft/yii2-$ext/blob/master/" . implode('/', $parts) . '.php';
break;
}

if ($line === null)
return $baseUrl . $url;
return $url;
else
return $baseUrl . $url . '#L' . $line;
return $url . '#L' . $line;
}
}
6 changes: 5 additions & 1 deletion templates/bootstrap/assets/css/api.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ table.summaryTable th {
margin: 5px 0;
padding:5px;
background:#FFF5E6;
}
}

img {
max-width: 100%;
}
4 changes: 0 additions & 4 deletions templates/html/ApiRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
*/
class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
{
/**
* @var string string to use as the title of the generated page.
*/
public $pageTitle;
/**
* @var string path or alias of the layout file to use.
*/
Expand Down
1 change: 0 additions & 1 deletion templates/html/GuideRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
abstract class GuideRenderer extends BaseGuideRenderer
{
public $pageTitle;
public $layout;

/**
Expand Down
3 changes: 3 additions & 0 deletions templates/html/views/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<?php if ($type instanceof ClassDoc && !empty($type->interfaces)): ?>
<tr><th>Implements</th><td><?= $renderer->renderInterfaces($type->interfaces) ?></td></tr>
<?php endif; ?>
<?php if ($type instanceof InterfaceDoc && !empty($type->parentInterfaces)): ?>
<tr><th>Implements</th><td><?= $renderer->renderInterfaces($type->parentInterfaces) ?></td></tr>
<?php endif; ?>
<?php if (!($type instanceof InterfaceDoc) && !empty($type->traits)): ?>
<tr><th>Uses Traits</th><td><?= $renderer->renderTraits($type->traits) ?></td></tr>
<?php endif; ?>
Expand Down
1 change: 0 additions & 1 deletion templates/online/ApiRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class ApiRenderer extends \yii\apidocchm\templates\html\ApiRenderer
{
public $layout = false;
public $indexView = '@yii/apidocchm/templates/online/views/index.php';
public $pageTitle = 'Yii Framework 2.0 API Documentation';


/**
Expand Down
2 changes: 2 additions & 0 deletions templates/pdf/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@


pdf:
# improve list spacing
sed -i 's/\\begin{itemize}/\\begin{itemize}[noitemsep,nolistsep]/' guide.tex
# run pdflatex twice to generate TOC correctly
pdflatex -halt-on-error main.tex
pdflatex -halt-on-error main.tex
Expand Down
6 changes: 6 additions & 0 deletions templates/pdf/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
%\usepackage[british,russian]{babel}
\usepackage[british]{babel}

% declare some unicode characters
\DeclareUnicodeCharacter{2713}{yes} %

% list spacing http://stackoverflow.com/questions/3275622/latex-remove-spaces-between-items-in-list
\usepackage{enumitem}

% url support
\usepackage{url}

Expand Down

0 comments on commit 8c91c00

Please sign in to comment.