Merge pull request #55 from camfindlay/branchalias

ENHANCEMENT optional branch property to allow version aliases.
This commit is contained in:
Will Rossiter 2015-01-07 14:10:50 +13:00
commit 9a2deea414
4 changed files with 151 additions and 103 deletions

View File

@ -128,6 +128,8 @@ class DocumentationManifest {
$version = (isset($details['Version'])) ? $details['Version'] : '';
$branch = (isset($details['Branch'])) ? $details['Branch'] : '';
$langs = scandir($path);
if($langs) {
@ -143,6 +145,7 @@ class DocumentationManifest {
$entity->setTitle($details['Title']);
$entity->setLanguage($lang);
$entity->setVersion($version);
$entity->setBranch($branch);
if(isset($details['Stable'])) {
$entity->setIsStable($details['Stable']);
@ -202,6 +205,7 @@ class DocumentationManifest {
'Path' => $docs,
'Title' => DocumentationHelper::clean_page_name($entity),
'Version' => 'master',
'Branch' => 'master',
'Stable' => true
);
}

View File

@ -592,6 +592,11 @@ class DocumentationViewer extends Controller {
$url = self::$edit_links[strtolower($entity->title)];
$version = $entity->getVersion();
if($entity->getBranch()){
$version = $entity->getBranch();
}
if($version == "trunk" && (isset($url['options']['rewritetrunktomaster']))) {
if($url['options']['rewritetrunktomaster']) {
$version = "master";

View File

@ -56,6 +56,13 @@ class DocumentationEntity extends ViewableData {
*/
protected $version;
/**
* The repository branch name (allows for $version to be an alias on development branches).
*
* @var string $branch
*/
protected $branch;
/**
* If this entity is a stable release or not. If it is not stable (i.e it
* could be a past or future release) then a warning message will be shown.
@ -213,6 +220,22 @@ class DocumentationEntity extends ViewableData {
return $this->version;
}
/**
* @param string
*/
public function setBranch($branch) {
$this->branch = $branch;
return $this;
}
/**
* @return float
*/
public function getBranch() {
return $this->branch;
}
/**
* @return string
*/
@ -269,6 +292,7 @@ class DocumentationEntity extends ViewableData {
'Key' => $this->key,
'Path' => $this->getPath(),
'Version' => $this->getVersion(),
'Branch' => $this->getBranch(),
'IsStable' => $this->getIsStable(),
'Language' => $this->getLanguage()
);

View File

@ -25,6 +25,21 @@ In YAML this looks like:
Path: "framework/docs/"
Title: "Framework Documentation"
###Branch aliases for the edit link (optional)
When using entities with multiple versions, one of the branches of documentation may be a development version. For example the 'master' branch. You may have an internally assigned version number for this registered in your .yml configuration.
If this version number is not the same as the branch name on the git repository the `getEditLinks` method will return an incorrect link to go and edit the documentation. In this case you can simply set an optional `branch` property on the entity which will be used in the edit link instead.
Example:
:::yml
DocumentationManifest:
register_entities:
-
Path: "framework/docs/"
Title: "Framework Documentation"
Version: "1.0"
Branch: "master"
## Permalinks