Skip to content

Commit f198950

Browse files
committed
feat: peak docs
1 parent 9fd53e9 commit f198950

15 files changed

Lines changed: 605 additions & 46 deletions

config/statamic-context-cli.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
return [
77
/*
88
|--------------------------------------------------------------------------
9-
| Documentation Storage
9+
| Statamic Documentation Storage
1010
|--------------------------------------------------------------------------
1111
|
12-
| Configuration for storing and managing Statamic documentation
12+
| Configuration for storing and managing Statamic core documentation
1313
|
1414
*/
1515
'docs' => [
@@ -26,4 +26,25 @@
2626
'reference',
2727
],
2828
],
29+
30+
/*
31+
|--------------------------------------------------------------------------
32+
| Statamic Peak Documentation Storage
33+
|--------------------------------------------------------------------------
34+
|
35+
| Configuration for storing and managing Statamic Peak documentation
36+
|
37+
*/
38+
'peak_docs' => [
39+
'storage_path' => storage_path('app/statamic-peak-docs'),
40+
'index_file' => storage_path('app/statamic-peak-docs/index.json'),
41+
'github_repo' => 'studio1902/statamic-peak-docs',
42+
'github_branch' => 'main',
43+
'collections' => [
44+
'docs',
45+
'docs/getting-started',
46+
'docs/features',
47+
'docs/other',
48+
],
49+
],
2950
];

src/Commands/StatamicContextCommand.php

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace StatamicContext\StatamicContext\Commands;
66

77
use Illuminate\Console\Command;
8-
use Symfony\Component\Console\Attribute\AsCommand;
98

109
class StatamicContextCommand extends Command
1110
{
@@ -22,36 +21,59 @@ public function handle(): int
2221
$this->newLine();
2322

2423
$this->components->twoColumnDetail(
25-
'<fg=cyan>docs:search</>',
24+
'<fg=cyan>statamic-context:docs:search</>',
2625
'Search through Statamic documentation'
2726
);
2827
$this->components->twoColumnDetail(
29-
'<fg=cyan>docs:get {id}</>',
28+
'<fg=cyan>statamic-context:docs:get {id}</>',
3029
'Retrieve a specific documentation entry by ID'
3130
);
3231
$this->components->twoColumnDetail(
33-
'<fg=cyan>docs:update</>',
32+
'<fg=cyan>statamic-context:docs:update</>',
3433
'Fetch and update documentation from GitHub'
3534
);
3635

36+
$this->newLine();
37+
$this->components->info('Peak Documentation Commands:');
38+
$this->newLine();
39+
40+
$this->components->twoColumnDetail(
41+
'<fg=cyan>statamic-context:peak</>',
42+
'Statamic Peak documentation commands'
43+
);
44+
$this->components->twoColumnDetail(
45+
'<fg=cyan>statamic-context:peak:search</>',
46+
'Search through Statamic Peak documentation'
47+
);
48+
$this->components->twoColumnDetail(
49+
'<fg=cyan>statamic-context:peak:get {id}</>',
50+
'Retrieve a specific Peak documentation entry by ID'
51+
);
52+
$this->components->twoColumnDetail(
53+
'<fg=cyan>statamic-context:peak:update</>',
54+
'Fetch and update Peak documentation from GitHub'
55+
);
56+
3757
$this->newLine();
3858
$this->components->info('Usage Examples:');
3959
$this->newLine();
4060

41-
$this->line(' <fg=gray># Interactive search</>');
42-
$this->line(' php artisan docs:search --interactive');
61+
$this->line(' <fg=gray># Search Statamic docs</>');
62+
$this->line(' php artisan statamic-context:docs:search --interactive');
4363
$this->newLine();
4464

45-
$this->line(' <fg=gray># Search with query</>');
46-
$this->line(' php artisan docs:search');
65+
$this->line(' <fg=gray># Search Peak docs</>');
66+
$this->line(' php artisan statamic-context:peak:search page-builder');
4767
$this->newLine();
4868

4969
$this->line(' <fg=gray># Get specific entry</>');
50-
$this->line(' php artisan docs:get core:collections');
70+
$this->line(' php artisan statamic-context:docs:get core:collections');
71+
$this->line(' php artisan statamic-context:peak:get features:page-builder');
5172
$this->newLine();
5273

5374
$this->line(' <fg=gray># Update documentation</>');
54-
$this->line(' php artisan docs:update');
75+
$this->line(' php artisan statamic-context:docs:update');
76+
$this->line(' php artisan statamic-context:peak:update');
5577

5678
return self::SUCCESS;
5779
}

src/Commands/StatamicContextGetCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use StatamicContext\StatamicContext\Contracts\DocumentationRepository;
99
use StatamicContext\StatamicContext\Exceptions\DocumentationException;
1010
use StatamicContext\StatamicContext\Models\Documentation;
11-
use Symfony\Component\Console\Attribute\AsCommand;
1211

1312
class StatamicContextGetCommand extends Command
1413
{

src/Commands/StatamicContextSearchCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use StatamicContext\StatamicContext\Contracts\DocumentationRepository;
1111
use StatamicContext\StatamicContext\Exceptions\DocumentationException;
1212
use StatamicContext\StatamicContext\Models\Documentation;
13-
use Symfony\Component\Console\Attribute\AsCommand;
1413

1514
use function Laravel\Prompts\confirm;
1615
use function Laravel\Prompts\select;
@@ -34,10 +33,11 @@ public function handle(DocumentationRepository $repository): int
3433

3534
// Check if query was provided as argument
3635
$query = $this->argument('query');
37-
36+
3837
if ($query) {
3938
// Direct search with provided query
4039
$this->searchDocumentation($query, $repository);
40+
4141
return self::SUCCESS;
4242
}
4343

@@ -68,7 +68,7 @@ private function handleInteractive(DocumentationRepository $repository): int
6868
$shouldUpdate = confirm('Would you like to update the documentation first?');
6969

7070
if ($shouldUpdate) {
71-
$this->components->info('Run: php artisan docs:update');
71+
$this->components->info('Run: php artisan statamic-context:docs:update');
7272

7373
return self::SUCCESS;
7474
}
@@ -129,7 +129,7 @@ private function displayHelp(DocumentationRepository $repository): void
129129
$this->newLine();
130130
$this->components->twoColumnDetail('<fg=gray>Usage</>', 'php artisan statamic-context:docs:search [query]');
131131
$this->components->twoColumnDetail('<fg=gray>Interactive</>', 'php artisan statamic-context:docs:search --interactive');
132-
$this->components->twoColumnDetail('<fg=gray>Update docs</>', 'php artisan docs:update');
132+
$this->components->twoColumnDetail('<fg=gray>Update docs</>', 'php artisan statamic-context:docs:update');
133133

134134
$this->newLine();
135135
$this->line('<fg=yellow>Examples:</>');
@@ -150,7 +150,7 @@ private function displayStatus(DocumentationRepository $repository): void
150150
"<fg=green>{$count} documents available</>"
151151
);
152152
} else {
153-
$this->components->warn('No documentation found. Run docs:update first.');
153+
$this->components->warn('No documentation found. Run statamic-context:docs:update first.');
154154
}
155155
}
156156

@@ -168,7 +168,7 @@ private function searchDocumentation(string $query, DocumentationRepository $rep
168168
$this->components->warn('No results found.');
169169
$this->newLine();
170170
$this->line('Try different search terms or update the documentation:');
171-
$this->line(' <fg=gray>php artisan docs:update</>');
171+
$this->line(' <fg=gray>php artisan statamic-context:docs:update</>');
172172

173173
return;
174174
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace StatamicContext\StatamicContext\Commands;
6+
7+
use Illuminate\Console\Command;
8+
9+
class StatamicPeakCommand extends Command
10+
{
11+
protected $signature = 'statamic-context:peak';
12+
13+
protected $description = 'Statamic Peak documentation commands';
14+
15+
public function handle(): int
16+
{
17+
$this->components->info('Statamic Peak Documentation CLI');
18+
$this->newLine();
19+
20+
$this->components->info('Available Commands:');
21+
$this->newLine();
22+
23+
$this->components->twoColumnDetail(
24+
'<fg=cyan>statamic-context:peak:search</>',
25+
'Search through Statamic Peak documentation'
26+
);
27+
$this->components->twoColumnDetail(
28+
'<fg=cyan>statamic-context:peak:get {id}</>',
29+
'Retrieve a specific Peak documentation entry by ID'
30+
);
31+
$this->components->twoColumnDetail(
32+
'<fg=cyan>statamic-context:peak:update</>',
33+
'Fetch and update Peak documentation from GitHub'
34+
);
35+
36+
$this->newLine();
37+
$this->components->info('Usage Examples:');
38+
$this->newLine();
39+
40+
$this->line(' <fg=gray># Interactive search</>');
41+
$this->line(' php artisan statamic-context:peak:search --interactive');
42+
$this->newLine();
43+
44+
$this->line(' <fg=gray># Search with query</>');
45+
$this->line(' php artisan statamic-context:peak:search');
46+
$this->newLine();
47+
48+
$this->line(' <fg=gray># Get specific entry</>');
49+
$this->line(' php artisan statamic-context:peak:get features:page-builder');
50+
$this->newLine();
51+
52+
$this->line(' <fg=gray># Update documentation</>');
53+
$this->line(' php artisan statamic-context:peak:update');
54+
55+
return self::SUCCESS;
56+
}
57+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace StatamicContext\StatamicContext\Commands;
6+
7+
use Illuminate\Console\Command;
8+
use StatamicContext\StatamicContext\Contracts\DocumentationRepository;
9+
use StatamicContext\StatamicContext\Exceptions\DocumentationException;
10+
use StatamicContext\StatamicContext\Models\Documentation;
11+
12+
class StatamicPeakGetCommand extends Command
13+
{
14+
protected $signature = 'statamic-context:peak:get
15+
{id : The ID of the Peak documentation entry to retrieve}
16+
{--format=text : Output format (text, json)}';
17+
18+
protected $description = 'Retrieve a specific Peak documentation entry by ID';
19+
20+
public function handle(DocumentationRepository $repository): int
21+
{
22+
try {
23+
$id = $this->argument('id');
24+
$format = $this->option('format');
25+
26+
if (! $repository->exists()) {
27+
$this->components->error('No Peak documentation found. Run statamic-context:peak:update first.');
28+
29+
return self::FAILURE;
30+
}
31+
32+
$doc = $repository->findById($id);
33+
34+
if (! $doc instanceof Documentation) {
35+
$this->components->error("Peak documentation entry with ID '{$id}' not found.");
36+
37+
return self::FAILURE;
38+
}
39+
40+
if ($format === 'json') {
41+
$this->outputJson($doc);
42+
} else {
43+
$this->outputText($doc);
44+
}
45+
46+
return self::SUCCESS;
47+
} catch (DocumentationException $e) {
48+
$this->components->error($e->getMessage());
49+
50+
return self::FAILURE;
51+
}
52+
}
53+
54+
private function outputJson(Documentation $doc): void
55+
{
56+
$data = [
57+
'id' => $doc->getId(),
58+
'title' => $doc->title,
59+
'collection' => $doc->collection,
60+
'github_url' => $doc->githubUrl,
61+
'content' => $doc->content,
62+
];
63+
64+
$this->line(json_encode($data, JSON_PRETTY_PRINT));
65+
}
66+
67+
private function outputText(Documentation $doc): void
68+
{
69+
$this->components->info("Peak Documentation Entry: {$doc->title}");
70+
$this->newLine();
71+
72+
$this->components->twoColumnDetail('<fg=cyan>ID</>', $doc->getId());
73+
$this->components->twoColumnDetail('<fg=cyan>Title</>', $doc->title);
74+
$this->components->twoColumnDetail('<fg=cyan>Collection</>', $doc->collection);
75+
$this->components->twoColumnDetail('<fg=cyan>GitHub URL</>', $doc->githubUrl);
76+
$this->newLine();
77+
78+
if ($doc->content) {
79+
$this->line('<fg=yellow>Content:</>');
80+
$this->newLine();
81+
$this->line($doc->content);
82+
} else {
83+
$this->components->warn('No content available for this entry.');
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)