Exemplo n.º 1
0
 /**
  * @param resource $handle
  * @param Definition[] $refs
  * @param Definition $def
  * @param Definition|null $prev
  * @param Definition|null $next
  */
 private function writeOutWikiEntry($handle, array $refs, $def, $prev, $next = null)
 {
     fwrite($handle, '# ' . $def->getName());
     fwrite($handle, "\n");
     if (count($def->getTags())) {
         fwrite($handle, "> tagged with: ");
         $implode = implode(', ', array_map(function ($tag) {
             return "[#{$tag}]({$tag})";
         }, $def->getTags()));
         fwrite($handle, "{$implode}\n");
     }
     fwrite($handle, "\n");
     fwrite($handle, $def->getMarkdown());
     $this->nl($handle);
     foreach ($def->getImages() as $image) {
         fwrite($handle, sprintf('![%1$s](img/%1$s.png)', $image));
         $this->nl($handle);
     }
     $this->hr($handle);
     fwrite($handle, "* [Go to Overview](Home)\n");
     foreach ($refs as $ref) {
         fwrite($handle, sprintf("* See also %s\n", $ref->getMarkdownLink()));
     }
     if ($prev) {
         fwrite($handle, sprintf("* Previous: %s\n", $prev->getMarkdownLink()));
     }
     if ($next) {
         fwrite($handle, sprintf("* Next: %s\n", $next->getMarkdownLink()));
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $line
  * @param Definition $definition
  * @return string
  */
 private function writeDefinition($line, Definition $definition)
 {
     $name = $definition->getName();
     $line .= $name . ': ';
     $annotations = array_merge($definition->getPrefix() ? [$definition->getPrefix()] : [], $this->formatTags($definition), $this->formatImages($definition));
     $line .= implode(' ', $annotations);
     $line .= $definition->toString();
     $line .= "\n";
     return $line;
 }