m7r/grunt-ngdocs — pull request #130 by LFDM (2014-12-12 02:07:21+00:00)
Title: Optional links to source code

Picks up #25

Adds support to optionally add source code links to the generated docs. They are present on several levels: To definitions of services/directives/filters, but also to individual methods/functions and properties (as long as they were defined with `@ngdoc`.

This is achieved by adding a `sourcePath` property to the ngdocs options in your Gruntfile. The path should be the root of your file tree. This is obviously targetted at pointing to a github repository - internal repositories can still be supported when someone points to a local file tree, but that probably means some work on the users side.

Right now the anchor tags are styled in GitHub's way (line numbers prefixed by an `L`, as in: `L27`). We can probably discuss to allow custom prefixes and only use `L` as default. One could also pass an object as `sourcePath`, something like
```
"sourcePath" : {
"path": "http://path.to.file.tree",
"anchorPrefix" : "myPrefix"
}
```
but it's a feature probably not really needed - not sure.

When no `sourcePath` is given in the Gruntfile, no links are added - the generated doc look exactly like before.

Take note that [https://github.com/LFDM/grunt-ngdocs/blob/d44d1d31f4cb5b326f7e9b7cbb6acfde495f196d/src/ngdoc.js#L504](this line) looks a bit silly, but it was the fastest way to get to nicely styled html... ;)

Here are some screenshots:

1. A doc page with source links

![grunt-ngdocs1](https://cloud.githubusercontent.com/assets/2204549/5405899/b0b41dba-81ab-11e4-9dbf-710652995959.png)

2. And this is where I arrive when I click the eye icon next to `addClickAction` - I have pointed my `sourcePath` to my GithubRepo, specifically to: http://github.com/latin-language-toolkit/arethusa/tree/doc

![grunt-ngdocs2](https://cloud.githubusercontent.com/assets/2204549/5405916/f855ecb6-81ab-11e4-9d7c-5480b34a6659.png)