Skip to content
This repository has been archived by the owner on Feb 16, 2019. It is now read-only.

Adding "View Source" link to the class page #91

Merged
merged 2 commits into from
May 30, 2015

Conversation

aik099
Copy link
Contributor

@aik099 aik099 commented Jun 27, 2014

This is an implementation of #63 task based on original commit made in #64.

_Usage_
By default Sami doesn't know on which hosting Git repository is located and doesn't add View Source links on class detail pages. However if you specify remote_repository option with instance of AbstractRemoteRepository class sub-class, then the View Source link would be added:

sami_viewsourcelink

For example:

array(
...
'remote_repository' => new GitHubRemoteRepository('username/repository', '/path/to/repository'),
...
)

The '/path/to/repository' is required, because Sami doesn't know base folder on GitHub (or any other service), where original files (for which documentation is being generated) live.

Thanks to @anlutro, which commit (squashed) was used as a base for my changes.

Closes #63

@aik099
Copy link
Contributor Author

aik099 commented Jun 27, 2014

@fabpot , the code style check is reporting issues that existed in changed files, but not in the code changed in this PR. For example Scrutinizer CI remembers what issues exists in master and only reports changes in the PR branch.

@aik099
Copy link
Contributor Author

aik099 commented Jun 27, 2014

I've rebased on master so now it can be merged from GitHub website.

@aik099
Copy link
Contributor Author

aik099 commented Jun 27, 2014

I've fixed CS issues reported by status.fabpot.io. I've kept is a separate commit, because CS violations weren't introduced by my changes.


public function __construct($name, $localPath)
{
$this->name = $name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is not used by the AbstractRemoteRepository so it should be moved to the GitHubRemoteRepository

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because I planned to create also BitBucketRemoteRepository, but wasn't able to do so due some stupid link building rules there where a link to a file always has latest commit sha, when that file was changed. Since we don't track commit sha associated with version/file, then it's impossible to build such links.

In general I would say that on all remote repositories a repository is identified by name, so having this property in parent abstract class made more sense to me.

@aik099
Copy link
Contributor Author

aik099 commented Jul 20, 2014

@fabpot , any opinion on this PR. Is it needed. If so, then what should I adjust for it to be merged?

@aik099
Copy link
Contributor Author

aik099 commented Jul 29, 2014

@fabpot , ping. Please see #91 (comment) .

@robfrawley
Copy link

Was anything like this PR ever integrated into Sami?

@aik099
Copy link
Contributor Author

aik099 commented May 27, 2015

@fabpot , another ping. If you need anything fixed, then I can do that. Otherwise if nobody has any objections, then please merge.

@@ -99,6 +102,7 @@ And here is how you can configure different versions:
'title' => 'Symfony2 API',
'build_dir' => __DIR__.'/../build/sf2/%version%',
'cache_dir' => __DIR__.'/../cache/sf2/%version%',
'remote_repository' => new GitHubRemoteRepository('symfony/symfony', dirname($dir)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be documented as an additional optional feature. Here, people might think this is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above says The``Sami``constructor optionally takes an array of options as a second argument: which kind of implies that all options are optional. Any ideas on how we can stress that fact even more, it's even needed?

@fabpot
Copy link
Member

fabpot commented May 28, 2015

This PR looks good to me.

1. refactoring to increase clarity of added logic
2. adding parenthesis around "View Source" link
3. updating documentation
4. adding "GitHubRemoteRepository" class import to the examples
@aik099
Copy link
Contributor Author

aik099 commented May 30, 2015

I've squashed and rebased PR so now it can be merged.

The failure of fabbot.io is:

  • not on the lines I've changed
  • probably caused by standard change, that isn't now allowing aligning of array key/value pairs

@fabpot
Copy link
Member

fabpot commented May 30, 2015

Thank you @aik099.

@fabpot fabpot merged commit a077a75 into FriendsOfPHP:master May 30, 2015
fabpot added a commit that referenced this pull request May 30, 2015
…099)

This PR was merged into the 3.0-dev branch.

Discussion
----------

Adding "View Source" link to the class page

This is an implementation of #63 task based on original commit made in #64.

___Usage___
By default Sami doesn't know on which hosting Git repository is located and doesn't add `View Source` links on class detail pages. However if you specify `remote_repository` option with instance of `AbstractRemoteRepository` class sub-class, then the `View Source` link would be added:

![sami_viewsourcelink](https://cloud.githubusercontent.com/assets/1277526/3411930/ed431ede-fdf8-11e3-89df-0d6019d5f51c.png)

For example:

```php
array(
...
'remote_repository' => new GitHubRemoteRepository('username/repository', '/path/to/repository'),
...
)
```
The `'/path/to/repository'` is required, because Sami doesn't know base folder on GitHub (or any other service), where original files (for which documentation is being generated) live.

Thanks to @anlutro, which commit (squashed) was used as a base for my changes.

Closes #63

Commits
-------

a077a75 Extracting url building logic to dedicated GitHubRemoteRepository class
21dcc46 Working prototype with class "View Source" links
@aik099 aik099 deleted the 63-view-source-link-feat branch May 30, 2015 16:33
@aik099
Copy link
Contributor Author

aik099 commented May 30, 2015

Thanks for merging, but apparently the Packagist hook doesn't work because it still referencing old commit for 3.0.0-DEV version.

@GrahamCampbell
Copy link
Contributor

This is a new feature. Don't we need to bump the minor version now?

mzur added a commit to mzur/Sami that referenced this pull request Oct 24, 2015
The link will be shown as the "at line ###" part for each method.
Using the link, the users can directly jump to the method source.

This is an extension of FriendsOfPHP#91
fabpot added a commit that referenced this pull request Jan 19, 2016
…nfigured (mzur)

This PR was merged into the 3.0-dev branch.

Discussion
----------

Add a link to class methods if a remote repository is configured

The link will be shown as the "at line ###" part for each method.
![link](https://cloud.githubusercontent.com/assets/2457311/10710148/7ee1c41a-7a4b-11e5-9092-d39b46f0435b.png)
Using the link, the users can directly jump to the method source.

This is an extension of #91

Commits
-------

6bac774 Add a link to class methods if a remote repository is configured
@dennisverspuij
Copy link

For anyone interested I brewed a solution to generate viewable source code along the API documentation, using GeSHi.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants