Browse Source

fixed several issues with apidoc generator

tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
c9c7db9ae5
  1. 2
      docs/guide/caching.md
  2. 5
      extensions/apidoc/commands/RenderController.php
  3. 3
      extensions/apidoc/composer.json
  4. 42
      extensions/apidoc/helpers/ApiMarkdown.php
  5. 2
      extensions/apidoc/templates/bootstrap/layouts/main.php
  6. 4
      framework/helpers/BaseMarkdown.php

2
docs/guide/caching.md

@ -61,7 +61,7 @@ is a summary of the available cache components:
the fastest one when dealing with cache in a distributed applications (e.g. with several servers, load
balancers, etc.)
* [[\yii\caching\RedisCache]]: implements a cache component based on [Redis](http://redis.io/) key-value store
* [[\yii\redis\Cache]]: implements a cache component based on [Redis](http://redis.io/) key-value store
(redis version 2.6.12 or higher is required).
* [[\yii\caching\WinCache]]: uses PHP [WinCache](http://iis.net/downloads/microsoft/wincache-extension)

5
extensions/apidoc/commands/RenderController.php

@ -65,6 +65,11 @@ class RenderController extends Controller
$this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
if (empty($files)) {
$this->stderr('Error: No php files found to process.' . PHP_EOL);
return 1;
}
$context = new Context();
$cacheFile = $targetDir . '/cache/' . md5(serialize($files)) . '.tmp';

3
extensions/apidoc/composer.json

@ -21,7 +21,8 @@
"require": {
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"phpdocumentor/reflection": ">=1.0.3"
"phpdocumentor/reflection": ">=1.0.3",
"nikic/php-parser": "0.9.*"
},
"autoload": {
"psr-4": { "yii\\apidoc\\": "" }

42
extensions/apidoc/helpers/ApiMarkdown.php

@ -30,6 +30,48 @@ class ApiMarkdown extends GithubMarkdown
protected $context;
/**
* @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
*/
protected function renderCode($block)

2
extensions/apidoc/templates/bootstrap/layouts/main.php vendored

@ -31,7 +31,7 @@ $this->beginPage();
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
'padded' => false,
'renderInnerContainer' => false,
'view' => $this,
]);
$extItems = [];

4
framework/helpers/BaseMarkdown.php

@ -57,7 +57,7 @@ class BaseMarkdown
public static function process($markdown, $flavor = 'original')
{
$parser = static::getParser($flavor);
return $parser->parse($parser);
return $parser->parse($markdown);
}
/**
@ -73,7 +73,7 @@ class BaseMarkdown
public static function processParagraph($markdown, $flavor = 'original')
{
$parser = static::getParser($flavor);
return $parser->parseParagraph($parser);
return $parser->parseParagraph($markdown);
}
/**

Loading…
Cancel
Save