Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Basic cross-referencing support for Diviner.

Summary: Allow linking to another project with @{type@project:name}
  • Loading branch information...
commit bdab98d3a466b6abdbafad058a6d66b017841fdc 1 parent 712331c
@epriestley epriestley authored
View
3  .gitignore
@@ -1,3 +1,4 @@
.DS_Store
._*
-docs/
+/docs/
+/.divinercache
View
3  src/docs/overview.diviner
@@ -1,6 +1,7 @@
@title Diviner Overview
-Diviner is a documentation generation system which supports multiple languages.
+Diviner is a documentation generation system which "supports" multiple
+languages.
= header =
View
17 src/remarkup/symbolrule/DivinerRemarkupRuleSymbols.php
@@ -32,7 +32,7 @@ public function getRenderer() {
public function apply($text) {
return preg_replace_callback(
- '/@{(\w+?):([^}]+?)}/',
+ '/@{([\w@]+?):([^}]+?)}/',
array($this, 'markupSymbol'),
$text);
}
@@ -41,6 +41,14 @@ public function markupSymbol($matches) {
$type = $matches[1];
$name = $matches[2];
+ // Collapse sequences of whitespace into a single space.
+ $name = preg_replace('/\s{2,}/', ' ', $name);
+
+ $project = null;
+ if (strpos($type, '@') !== false) {
+ list($type, $project) = explode('@', $type, 2);
+ }
+
switch ($type) {
case 'method':
$context = $this->getEngine()->getConfig('diviner.context');
@@ -59,7 +67,8 @@ public function markupSymbol($matches) {
$type,
$class,
phutil_escape_html($name).$suffix,
- 'method/'.$method));
+ 'method/'.$method,
+ $project));
case 'function':
$suffix = '()';
break;
@@ -72,7 +81,9 @@ public function markupSymbol($matches) {
$this->getRenderer()->renderAtomLinkRaw(
$type,
$name,
- phutil_escape_html($name).$suffix));
+ phutil_escape_html($name).$suffix,
+ $anchor = null,
+ $project));
}
}
View
8 src/renderer/default/DivinerDefaultRenderer.php
@@ -274,7 +274,9 @@ public function renderAtomLinkRaw(
$type,
$name,
$link_text = null,
- $anchor = null) {
+ $anchor = null,
+ $project = null) {
+
if ($link_text === null) {
$link_text = phutil_escape_html($name);
}
@@ -287,6 +289,10 @@ public function renderAtomLinkRaw(
$anchor = '#'.$this->getNormalizedName($anchor);
}
+ if ($project) {
+ $base .= "../{$project}/";
+ }
+
return phutil_render_tag(
'a',
array(
Please sign in to comment.
Something went wrong with that request. Please try again.