process() public static method

Converts markdown into HTML
public static process ( string $content, yii\apidoc\models\TypeDoc $context = null, boolean $paragraph = false ) : string
$content string
$context yii\apidoc\models\TypeDoc
$paragraph boolean
return string
Esempio n. 1
0
 /**
  * Renders a given [[Context]].
  *
  * @param Controller $controller the apidoc controller instance. Can be used to control output.
  */
 public function render($files, $targetDir)
 {
     $this->_targetDir = $targetDir;
     $fileCount = count($files) + 1;
     if ($this->controller !== null) {
         Console::startProgress(0, $fileCount, 'Rendering markdown files: ', false);
     }
     $done = 0;
     $fileData = [];
     $headlines = [];
     foreach ($files as $file) {
         $fileData[$file] = file_get_contents($file);
         if (basename($file) == 'index.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) {
         $output = ApiMarkdown::process($content);
         // TODO generate links to yiiframework.com by default
         $output = $this->fixMarkdownLinks($output);
         if ($this->layout !== false) {
             $params = ['headlines' => $headlines, 'currentFile' => $file, 'content' => $output];
             $output = $this->getView()->renderFile($this->layout, $params, $this);
         }
         $fileName = $this->generateGuideFileName($file);
         file_put_contents($targetDir . '/' . $fileName, $output);
         if ($this->controller !== null) {
             Console::updateProgress(++$done, $fileCount);
         }
     }
     if ($this->controller !== null) {
         Console::updateProgress(++$done, $fileCount);
         Console::endProgress(true);
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
 }
Esempio n. 2
0
    ?>
 id="<?php 
    echo $event->name;
    ?>
">
        <td><?php 
    echo $renderer->createSubjectLink($event);
    ?>
</td>
        <td><?php 
    echo $renderer->createTypeLink($event->types);
    ?>
</td>
        <td>
            <?php 
    echo ApiMarkdown::process($event->shortDescription, $event->definedBy, true);
    ?>
            <?php 
    if (!empty($event->since)) {
        ?>
                (available since version <?php 
        echo $event->since;
        ?>
)
            <?php 
    }
    ?>
        </td>
        <td><?php 
    echo $renderer->createTypeLink($event->definedBy);
    ?>
Esempio n. 3
0
</td>
                </tr>
            <?php 
        }
        ?>
            <?php 
        foreach ($method->exceptions as $exception => $description) {
            ?>
                <tr>
                  <th class="param-name-col">throws</th>
                  <td class="param-type-col"><?php 
            echo $renderer->createTypeLink($exception);
            ?>
</td>
                  <td class="param-desc-col"><?php 
            echo ApiMarkdown::process($description, $type);
            ?>
</td>
                </tr>
            <?php 
        }
        ?>
        <?php 
    }
    ?>
    </table>

<!--	--><?php 
    //$this->renderPartial('sourceCode',array('object'=>$method));
    ?>
Esempio n. 4
0
<h1>Class Reference</h1>

<table class="summaryTable docIndex">
    <colgroup>
        <col class="col-package" />
        <col class="col-class" />
        <col class="col-description" />
    </colgroup>
    <tr>
        <th>Class</th>
        <th>Description</th>
    </tr>
<?php 
ksort($types);
foreach ($types as $i => $class) {
    ?>
    <tr>
        <td><?php 
    echo $this->context->typeLink($class, $class->name);
    ?>
</td>
        <td><?php 
    echo \yii\apidoc\helpers\ApiMarkdown::process($class->shortDescription, $class, true);
    ?>
</td>
    </tr>
<?php 
}
?>
</table>
Esempio n. 5
0
        of type <?php 
    echo $renderer->createTypeLink($event->types);
    ?>
        <?php 
    if (!empty($event->since)) {
        ?>
            (available since version <?php 
        echo $event->since;
        ?>
)
        <?php 
    }
    ?>
        </span>
    </div>

    <div class="doc-description">
        <?php 
    echo ApiMarkdown::process($event->description, $type);
    ?>

        <?php 
    echo $this->render('seeAlso', ['object' => $event]);
    ?>
    </div>

<?php 
}
?>
</div>
Esempio n. 6
0
    <tr<?php 
        echo $property->definedBy != $type->name ? ' class="inherited"' : '';
        ?>
 id="<?php 
        echo $property->name;
        ?>
">
        <td><?php 
        echo $renderer->createSubjectLink($property);
        ?>
</td>
        <td><?php 
        echo $renderer->createTypeLink($property->types);
        ?>
</td>
        <td><?php 
        echo ApiMarkdown::process($property->shortDescription, $property->definedBy, true);
        ?>
</td>
        <td><?php 
        echo $renderer->createTypeLink($property->definedBy);
        ?>
</td>
    </tr>
    <?php 
    }
}
?>
</table>
</div>
Esempio n. 7
0
    ?>
 id="<?php 
    echo $constant->name;
    ?>
">
          <td id="<?php 
    echo $constant->name;
    ?>
-detail"><?php 
    echo $constant->name;
    ?>
</td>
          <td><?php 
    echo $constant->value;
    ?>
</td>
          <td><?php 
    echo ApiMarkdown::process($constant->shortDescription . "\n" . $constant->description, $constant->definedBy, true);
    ?>
</td>
          <td><?php 
    echo $renderer->createTypeLink($constant->definedBy);
    ?>
</td>
        </tr>
    <?php 
}
?>
    </table>
</div>
Esempio n. 8
0
    ?>
    <?php 
    if ($protected && $method->visibility == 'protected' || !$protected && $method->visibility != 'protected') {
        ?>
    <tr<?php 
        echo $method->definedBy != $type->name ? ' class="inherited"' : '';
        ?>
 id="<?php 
        echo $method->name;
        ?>
()">
        <td><?php 
        echo $renderer->createSubjectLink($method, $method->name . '()');
        ?>
</td>
        <td><?php 
        echo ApiMarkdown::process($method->shortDescription, $method->definedBy, true);
        ?>
</td>
        <td><?php 
        echo $renderer->createTypeLink($method->definedBy, $type);
        ?>
</td>
    </tr>
    <?php 
    }
}
?>
</table>
</div>
Esempio n. 9
0
        if (!empty($property->deprecatedSince)) {
            echo 'since version ' . $property->deprecatedSince . ': ';
        }
        if (!empty($property->deprecatedReason)) {
            echo ApiMarkdown::process($property->deprecatedReason, $type, true);
        }
        ?>
</strong>
        </div>
    <?php 
    }
    ?>

    <div class="doc-description">
        <?php 
    echo ApiMarkdown::process($property->description, $type);
    ?>

        <?php 
    echo $this->render('seeAlso', ['object' => $property]);
    ?>
    </div>

    <div class="signature"><?php 
    echo $renderer->renderPropertySignature($property, $type);
    ?>
</div>

<?php 
}
?>
Esempio n. 10
0
<?php

/* @var $object yii\apidoc\models\BaseDoc */
/* @var $this yii\web\View */
$type = $object instanceof \yii\apidoc\models\TypeDoc ? $object : $object->definedBy;
$see = [];
foreach ($object->tags as $tag) {
    /** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */
    if (get_class($tag) == 'phpDocumentor\\Reflection\\DocBlock\\Tag\\SeeTag') {
        $ref = $tag->getReference();
        if (strpos($ref, '://') === false) {
            $ref = '[[' . $ref . ']]';
        }
        $see[] = rtrim(\yii\apidoc\helpers\ApiMarkdown::process($ref . ' ' . $tag->getDescription(), $type, true), ". \r\n");
    }
}
if (empty($see)) {
    return;
} elseif (count($see) == 1) {
    echo '<p>See also ' . reset($see) . '.</p>';
} else {
    echo '<p>See also:</p><ul>';
    foreach ($see as $ref) {
        if (!empty($ref)) {
            if (substr_compare($ref, '>', -1, 1)) {
                $ref .= '.';
            }
            echo "<li>{$ref}</li>";
        }
    }
    echo '</ul>';
Esempio n. 11
0
<?php

/**
 * @var yii\apidoc\models\BaseDoc $object
 * @var yii\web\View $this
 */
$see = [];
foreach ($object->tags as $tag) {
    /** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */
    if (get_class($tag) == 'phpDocumentor\\Reflection\\DocBlock\\Tag\\SeeTag') {
        $ref = $tag->getReference();
        if (strpos($ref, '://') === false) {
            $ref = '[[' . $ref . ']]';
        }
        $see[] = rtrim(\yii\apidoc\helpers\ApiMarkdown::process($ref . ' ' . $tag->getDescription(), $object->definedBy, true), ". \r\n");
    }
}
if (empty($see)) {
    return;
} elseif (count($see) == 1) {
    echo '<p>See also ' . reset($see) . '.</p>';
} else {
    echo '<p>See also:</p><ul>';
    foreach ($see as $ref) {
        if (substr($ref, -1, 1) != '>') {
            $ref .= '.';
        }
        echo "<li>{$ref}</li>";
    }
    echo '</ul>';
}
Esempio n. 12
0
          <td><?php 
    echo $constant->value;
    ?>
</td>
          <td><?php 
    echo ApiMarkdown::process($constant->shortDescription . "\n" . $constant->description, $constant->definedBy, true);
    ?>
              <?php 
    if (!empty($constant->deprecatedSince) || !empty($constant->deprecatedReason)) {
        ?>
                  <strong>Deprecated <?php 
        if (!empty($constant->deprecatedSince)) {
            echo 'since version ' . $constant->deprecatedSince . ': ';
        }
        if (!empty($constant->deprecatedReason)) {
            echo ApiMarkdown::process($constant->deprecatedReason, $type, true);
        }
        ?>
</strong>
              <?php 
    }
    ?>
          </td>
          <td><?php 
    echo $renderer->createTypeLink($constant->definedBy);
    ?>
</td>
        </tr>
    <?php 
}
?>