mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
Fix some CBF linting issues. Improved a couple of doc blocks.
This commit is contained in:
parent
a9130a33db
commit
909cfd695f
@ -157,7 +157,7 @@ class DocumentationManifest
|
||||
if (isset($possible[$lang])) {
|
||||
/**
|
||||
* @var DocumentationEntity $entity
|
||||
*/
|
||||
*/
|
||||
$entity = Injector::inst()->create(
|
||||
'DocumentationEntity', $key
|
||||
);
|
||||
@ -770,7 +770,7 @@ class DocumentationManifest
|
||||
|
||||
/**
|
||||
* @var DocumentationEntity $check
|
||||
*/
|
||||
*/
|
||||
foreach ($this->getEntities() as $check) {
|
||||
if ($check->getKey() == $entity->getKey()) {
|
||||
if ($check->getLanguage() == $entity->getLanguage()) {
|
||||
|
@ -30,11 +30,11 @@ class DocumentationParser
|
||||
* Pathparts: folder/subfolder/page
|
||||
*
|
||||
* @param DocumentationPage $page
|
||||
* @param String $baselink Link relative to webroot, up until the "root" of the module. Necessary to rewrite relative links
|
||||
* of the module. Necessary to rewrite relative
|
||||
* links
|
||||
* @param string $baselink Link relative to webroot, up until the "root" of the module.
|
||||
* Necessary to rewrite relative links of the module. Necessary
|
||||
* to rewrite relative links
|
||||
*
|
||||
* @return String
|
||||
* @return string
|
||||
*/
|
||||
public static function parse(DocumentationPage $page, $baselink = null)
|
||||
{
|
||||
|
@ -658,8 +658,6 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
||||
if ($page) {
|
||||
$entity = $page->getEntity();
|
||||
|
||||
|
||||
|
||||
if ($entity && isset(self::$edit_links[strtolower($entity->title)])) {
|
||||
|
||||
// build the edit link, using the version defined
|
||||
@ -671,7 +669,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
||||
}
|
||||
|
||||
|
||||
if ($version == "trunk" && (isset($url['options']['rewritetrunktomaster']))) {
|
||||
if ($version == 'trunk' && (isset($url['options']['rewritetrunktomaster']))) {
|
||||
if ($url['options']['rewritetrunktomaster']) {
|
||||
$version = "master";
|
||||
}
|
||||
@ -699,7 +697,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
||||
* Returns the next page. Either retrieves the sibling of the current page
|
||||
* or return the next sibling of the parent page.
|
||||
*
|
||||
* @return DocumentationPage
|
||||
* @return DocumentationPage|null
|
||||
*/
|
||||
public function getNextPage()
|
||||
{
|
||||
@ -714,7 +712,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
||||
* Returns the previous page. Either returns the previous sibling or the
|
||||
* parent of this page
|
||||
*
|
||||
* @return DocumentationPage
|
||||
* @return DocumentationPage|null
|
||||
*/
|
||||
public function getPreviousPage()
|
||||
{
|
||||
@ -726,7 +724,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|void
|
||||
*/
|
||||
public function getGoogleAnalyticsCode()
|
||||
{
|
||||
@ -745,6 +743,9 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
||||
return $this->config()->get('documentation_title');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDocumentationBaseHref()
|
||||
{
|
||||
return Config::inst()->get('DocumentationViewer', 'link_base');
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package docsviewer
|
||||
*/
|
||||
class DocumentationViewerVersionWarning extends Extension
|
||||
{
|
||||
/**
|
||||
* Check to see if the currently accessed version is out of date or perhaps a
|
||||
* future version rather than the stable edition.
|
||||
*
|
||||
* @return false|ArrayData
|
||||
*/
|
||||
|
||||
class DocumentationViewerVersionWarning extends Extension
|
||||
{
|
||||
public function VersionWarning()
|
||||
{
|
||||
$page = $this->owner->getPage();
|
||||
@ -32,7 +33,7 @@ class DocumentationViewerVersionWarning extends Extension
|
||||
$stable = $this->owner->getManifest()->getStableVersion($entity);
|
||||
$compare = $entity->compare($stable);
|
||||
|
||||
if ($entity->getVersion() == "master" || $compare > 0) {
|
||||
if ($entity->getVersion() == 'master' || $compare > 0) {
|
||||
return $this->owner->customise(
|
||||
new ArrayData(
|
||||
array(
|
||||
|
@ -321,7 +321,6 @@ class DocumentationEntity extends ViewableData
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPath($path)
|
||||
@ -350,8 +349,6 @@ class DocumentationEntity extends ViewableData
|
||||
return $this->stable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns an integer value based on if a given version is the latest
|
||||
* version. Will return -1 for if the version is older, 0 if versions are
|
||||
@ -367,7 +364,7 @@ class DocumentationEntity extends ViewableData
|
||||
|
||||
// Normalise versions prior to comparison
|
||||
$dots = substr_count($v1, '.') - substr_count($v2, '.');
|
||||
while($dots > 0) {
|
||||
while ($dots > 0) {
|
||||
$dots--;
|
||||
$v2 .= '.99999';
|
||||
}
|
||||
|
@ -73,8 +73,10 @@ class DocumentationPage extends ViewableData
|
||||
|
||||
$titleParts = array_map(
|
||||
array(
|
||||
'DocumentationHelper', 'clean_page_name'
|
||||
), $pathParts
|
||||
'DocumentationHelper',
|
||||
'clean_page_name'
|
||||
),
|
||||
$pathParts
|
||||
);
|
||||
|
||||
$titleParts = array_filter(
|
||||
@ -111,7 +113,7 @@ class DocumentationPage extends ViewableData
|
||||
|
||||
$page = DocumentationHelper::clean_page_name($this->filename);
|
||||
|
||||
if ($page == "Index") {
|
||||
if ($page == 'Index') {
|
||||
return $this->getTitleFromFolder();
|
||||
}
|
||||
|
||||
@ -150,7 +152,7 @@ class DocumentationPage extends ViewableData
|
||||
*
|
||||
* @param boolean $removeMetaData
|
||||
*
|
||||
* @return string
|
||||
* @return string|false
|
||||
*/
|
||||
public function getMarkdown($removeMetaData = false)
|
||||
{
|
||||
@ -175,6 +177,9 @@ class DocumentationPage extends ViewableData
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIntroduction()
|
||||
{
|
||||
if (!$this->read) {
|
||||
@ -213,10 +218,12 @@ class DocumentationPage extends ViewableData
|
||||
$path = $this->getRelativePath();
|
||||
$url = explode('/', $path);
|
||||
$url = implode(
|
||||
'/', array_map(
|
||||
'/',
|
||||
array_map(
|
||||
function ($a) {
|
||||
return DocumentationHelper::clean_page_url($a);
|
||||
}, $url
|
||||
},
|
||||
$url
|
||||
)
|
||||
);
|
||||
|
||||
@ -307,6 +314,9 @@ class DocumentationPage extends ViewableData
|
||||
return $this->entity->getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf(get_class($this) .': %s)', $this->getPath());
|
||||
|
@ -9,7 +9,8 @@ class DocumentationHelperTests extends SapphireTest
|
||||
public function testCleanName()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"File path", DocumentationHelper::clean_page_name(
|
||||
'File path',
|
||||
DocumentationHelper::clean_page_name(
|
||||
'00_file-path.md'
|
||||
)
|
||||
);
|
||||
@ -18,13 +19,15 @@ class DocumentationHelperTests extends SapphireTest
|
||||
public function testCleanUrl()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"some_path", DocumentationHelper::clean_page_url(
|
||||
'some_path',
|
||||
DocumentationHelper::clean_page_url(
|
||||
'Some Path'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"somefilepath", DocumentationHelper::clean_page_url(
|
||||
'somefilepath',
|
||||
DocumentationHelper::clean_page_url(
|
||||
'00_SomeFilePath.md'
|
||||
)
|
||||
);
|
||||
@ -33,19 +36,22 @@ class DocumentationHelperTests extends SapphireTest
|
||||
public function testTrimSortNumber()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'file', DocumentationHelper::trim_sort_number(
|
||||
'file',
|
||||
DocumentationHelper::trim_sort_number(
|
||||
'0_file'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'2.1', DocumentationHelper::trim_sort_number(
|
||||
'2.1',
|
||||
DocumentationHelper::trim_sort_number(
|
||||
'2.1'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'dev/tasks/2.1', DocumentationHelper::trim_sort_number(
|
||||
'dev/tasks/2.1',
|
||||
DocumentationHelper::trim_sort_number(
|
||||
'dev/tasks/2.1'
|
||||
)
|
||||
);
|
||||
@ -54,13 +60,15 @@ class DocumentationHelperTests extends SapphireTest
|
||||
public function testTrimExtension()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'file', DocumentationHelper::trim_extension_off(
|
||||
'file',
|
||||
DocumentationHelper::trim_extension_off(
|
||||
'file.md'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'dev/path/file', DocumentationHelper::trim_extension_off(
|
||||
'dev/path/file',
|
||||
DocumentationHelper::trim_extension_off(
|
||||
'dev/path/file.md'
|
||||
)
|
||||
);
|
||||
@ -69,19 +77,22 @@ class DocumentationHelperTests extends SapphireTest
|
||||
public function testGetExtension()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'md', DocumentationHelper::get_extension(
|
||||
'md',
|
||||
DocumentationHelper::get_extension(
|
||||
'file.md'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'md', DocumentationHelper::get_extension(
|
||||
'md',
|
||||
DocumentationHelper::get_extension(
|
||||
'dev/tasks/file.md'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'txt', DocumentationHelper::get_extension(
|
||||
'txt',
|
||||
DocumentationHelper::get_extension(
|
||||
'dev/tasks/file.txt'
|
||||
)
|
||||
);
|
||||
|
@ -108,7 +108,8 @@ class DocumentationManifestTests extends SapphireTest
|
||||
// get next page at the end of one subfolder goes back up to the top
|
||||
// most directory
|
||||
$this->assertStringEndsWith(
|
||||
'2.3/test/', $this->manifest->getNextPage(
|
||||
'2.3/test/',
|
||||
$this->manifest->getNextPage(
|
||||
DOCSVIEWER_PATH . '/tests/docs/en/subfolder/subsubfolder/subsubpage.md',
|
||||
DOCSVIEWER_PATH . '/tests/docs/en/'
|
||||
)->Link
|
||||
@ -116,7 +117,8 @@ class DocumentationManifestTests extends SapphireTest
|
||||
|
||||
// after sorting, 2 is shown.
|
||||
$this->assertContains(
|
||||
'/intermediate/', $this->manifest->getNextPage(
|
||||
'/intermediate/',
|
||||
$this->manifest->getNextPage(
|
||||
DOCSVIEWER_PATH . '/tests/docs/en/sort/01-basic.md',
|
||||
DOCSVIEWER_PATH . '/tests/docs/en/'
|
||||
)->Link
|
||||
@ -125,7 +127,8 @@ class DocumentationManifestTests extends SapphireTest
|
||||
|
||||
// next gets the following URL
|
||||
$this->assertContains(
|
||||
'/test/', $this->manifest->getNextPage(
|
||||
'/test/',
|
||||
$this->manifest->getNextPage(
|
||||
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/index.md',
|
||||
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/'
|
||||
)->Link
|
||||
@ -145,7 +148,8 @@ class DocumentationManifestTests extends SapphireTest
|
||||
{
|
||||
// goes right into subfolders
|
||||
$this->assertContains(
|
||||
'subfolder/subsubfolder/subsubpage', $this->manifest->getPreviousPage(
|
||||
'subfolder/subsubfolder/subsubpage',
|
||||
$this->manifest->getPreviousPage(
|
||||
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
|
||||
DOCSVIEWER_PATH . '/tests/docs/en/'
|
||||
)->Link
|
||||
@ -186,7 +190,7 @@ class DocumentationManifestTests extends SapphireTest
|
||||
|
||||
$this->assertDOSContains(
|
||||
$expected, $this->manifest->getChildrenFor(
|
||||
DOCSVIEWER_PATH . "/tests/docs/en/"
|
||||
DOCSVIEWER_PATH . '/tests/docs/en/'
|
||||
)
|
||||
);
|
||||
|
||||
@ -197,7 +201,8 @@ class DocumentationManifestTests extends SapphireTest
|
||||
);
|
||||
|
||||
$this->assertDOSContains(
|
||||
$expected, $this->manifest->getChildrenFor(
|
||||
$expected,
|
||||
$this->manifest->getChildrenFor(
|
||||
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/',
|
||||
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/ChangeLog.md'
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user