Passed
Push — master ( 121290...ef5b2f )
by Caen
06:26 queued 03:36
created

DocumentationPage::hasTableOfContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 1
c 1
b 1
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Pages;
6
7
use Hyde\Framework\Actions\GeneratesSidebarTableOfContents;
8
use Hyde\Markdown\Contracts\FrontMatter\DocumentationPageSchema;
9
use Hyde\Pages\Concerns\BaseMarkdownPage;
10
use Hyde\Support\Models\Route;
11
12
/**
13
 * Page class for documentation pages.
14
 *
15
 * Documentation pages are stored in the _docs directory and using the .md extension.
16
 * The Markdown will be compiled to HTML using the documentation page layout to the _site/docs/ directory.
17
 *
18
 * @see https://hydephp.com/docs/master/documentation-pages
19
 */
20
class DocumentationPage extends BaseMarkdownPage implements DocumentationPageSchema
0 ignored issues
show
Deprecated Code introduced by
The interface Hyde\Markdown\Contracts\...DocumentationPageSchema has been deprecated: The navigation is inherited by the parent page, and the category is not documented, thus presumed to be unused. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
class DocumentationPage extends BaseMarkdownPage implements /** @scrutinizer ignore-deprecated */ DocumentationPageSchema

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.

Loading history...
21
{
22
    use Concerns\UsesFlattenedOutputPaths;
23
24
    public static string $sourceDirectory = '_docs';
25
    public static string $outputDirectory = 'docs';
26
    public static string $template = 'hyde::layouts/docs';
27
28
    public static function home(): ?Route
29
    {
30
        return Route::get(static::$outputDirectory.'/index');
31
    }
32
33
    /** @see https://hydephp.com/docs/master/documentation-pages#automatic-edit-page-button */
34
    public function getOnlineSourcePath(): string|false
35
    {
36
        if (config('docs.source_file_location_base') === null) {
37
            return false;
38
        }
39
40
        return trim(config('docs.source_file_location_base'), '/').'/'.$this->identifier.'.md';
41
    }
42
43
    public static function hasTableOfContents(): bool
44
    {
45
        return config('docs.table_of_contents.enabled', true);
46
    }
47
48
    /**
49
     * Generate Table of Contents as HTML from a Markdown document body.
50
     */
51
    public function getTableOfContents(): string
52
    {
53
        return (new GeneratesSidebarTableOfContents($this->markdown))->execute();
54
    }
55
}
56