6 * The complete available reference
8 class Reference
implements \IteratorAggregate
{
10 * List of mdref repositories
13 private $repos = array();
16 * @param array $refs list of mdref repository paths
18 public function __construct(array $refs) {
19 foreach ($refs as $path) {
20 $repo = new Repo($path);
21 $this->repos
[$repo->getName()] = $repo;
26 * Lookup the repo containing a ref entry
27 * @param string $entry requested reference entry, e.g. "pq/Connection/exec"
28 * @param type $canonical
29 * @return \mdref\Repo|NULL
31 public function getRepoForEntry($entry, &$canonical = null) {
32 foreach ($this->repos
as $repo) {
33 if ($repo->hasEntry($entry, $canonical)) {
40 * Implements \IteratorAggregate
41 * @return \ArrayIterator repository list
43 public function getIterator() {
44 return new \
ArrayIterator($this->repos
);
47 public function formatString($string) {
48 $md = \MarkdownDocument
::createFromString($string);
49 $md->compile(\MarkdownDocument
::AUTOLINK
);
50 return $md->getHtml();
53 public function formatFile($file) {
54 $fd = fopen($file, "r");
55 $md = \MarkdownDocument
::createFromStream($fd);
56 $md->compile(\MarkdownDocument
::AUTOLINK | \MarkdownDocument
::TOC
);
57 $html = $md->getHtml();