1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Containers\Documentation\Tasks; |
4
|
|
|
|
5
|
|
|
use App\Containers\Documentation\Traits\DocsGeneratorTrait; |
6
|
|
|
use App\Ship\Parents\Tasks\Task; |
7
|
|
|
use Illuminate\Support\Facades\Config; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class RenderTemplatesTask. |
11
|
|
|
* |
12
|
|
|
* @author Mahmoud Zalt <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class RenderTemplatesTask extends Task |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
use DocsGeneratorTrait; |
18
|
|
|
|
19
|
|
|
protected $headerMarkdownContent; |
20
|
|
|
|
21
|
|
|
const TEMPLATE_PATH = 'Containers/Documentation/ApiDocJs/shared/'; |
22
|
|
|
const OUTPUT_PATH = 'api-rendered-markdowns/'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Read the markdown header template and fill it with some real data from the .env file. |
26
|
|
|
*/ |
27
|
|
|
public function run() |
28
|
|
|
{ |
29
|
|
|
// read the template file |
30
|
|
|
$this->headerMarkdownContent = file_get_contents(app_path(self::TEMPLATE_PATH . 'header.template.md')); |
31
|
|
|
|
32
|
|
|
$this->replace('api.domain.dev', Config::get('api.domain')); |
33
|
|
|
$this->replace('{{rate-limit-expires}}', Config::get('hello.api.limit_expires')); |
34
|
|
|
$this->replace('{{rate-limit}}', Config::get('hello.api.limit')); |
35
|
|
|
$this->replace('{{token-expires}}', $this->minutesToTimeDisplay(Config::get('jwt.ttl'))); |
36
|
|
|
$this->replace('{{token-expires-minutes}}', Config::get('jwt.ttl')); |
37
|
|
|
$this->replace('{{pagination-limit}}', Config::get('repository.pagination.limit')); |
38
|
|
|
|
39
|
|
|
// this is what the apidoc.json file will point to to load the header.md |
40
|
|
|
// example: "filename": "../public/api-rendered-markdowns/header.md" |
|
|
|
|
41
|
|
|
$path = public_path(self::OUTPUT_PATH . 'header.md'); |
42
|
|
|
|
43
|
|
|
// write the actual file |
44
|
|
|
file_put_contents($path, $this->headerMarkdownContent); |
45
|
|
|
|
46
|
|
|
return $path; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.