Permalink
Browse files

Link Diviner sources in generated docs

Summary:
This fixes also wrong line links in Phabricator.

NOTE: BC break.

Test Plan:
  bin/diviner .

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2182
  • Loading branch information...
1 parent 66d5dce commit 7eff8c8fb69c1d0f32bf6ce7e042f23c651a6d34 vrana committed Apr 10, 2012
Showing with 20 additions and 4 deletions.
  1. +2 −0 .divinerconfig
  2. +10 −0 src/docs/overview.diviner
  3. +8 −4 src/renderer/default/DivinerDefaultRenderer.php
View
2 .divinerconfig
@@ -1,5 +1,7 @@
{
"name" : "Diviner",
+ "src_link" :
+ "https://secure.phabricator.com/diffusion/DIV/browse/master/%f$%l",
"engines" : [
["DivinerArticleEngine", {}],
["DivinerXHPEngine", {}]
View
10 src/docs/overview.diviner
@@ -3,6 +3,16 @@
Diviner is a documentation generation system which "supports" multiple
languages.
+= Configuration =
+
+Valid configuration directives in `.divinerconfig`:
+
+- `name`
+- `src_link` - `%f` stands for file, `%l` for line, `%%` for %
+- `groups`
+- `engines`
+- `phutil_libraries`
+
= header =
== h3 ==
View
12 src/renderer/default/DivinerDefaultRenderer.php
@@ -402,16 +402,20 @@ public function renderGroup($group) {
public function renderFileAndLine($file, $line) {
- $src_base = $this->getProjectConfiguration()->getConfig('src_base');
- if (!$src_base) {
+ $src_link = $this->getProjectConfiguration()->getConfig('src_link');
+ if (!$src_link) {
return phutil_escape_html($file.':'.$line);
}
return phutil_render_tag(
'a',
array(
- 'href' => $src_base.'/'.$file.'#L'.$line,
- 'target' => 'blank',
+ 'href' => strtr($src_link, array(
+ '%%' => '%',
+ '%f' => phutil_escape_uri($file),
+ '%l' => phutil_escape_uri($line),
+ )),
+ 'target' => 'blank',
),
phutil_escape_html($file.':'.$line));
}

0 comments on commit 7eff8c8

Please sign in to comment.