Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build/api-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

require __DIR__ . '/../vendor/autoload.php';

use Gacela\Framework\Gacela;
use Phel\Phel;
use PhelWeb\ApiGenerator\Facade as ApiGeneratorFacade;

Gacela::bootstrap(__DIR__, Phel::configFn());
Phel::bootstrap(__DIR__);

$facade = new ApiGeneratorFacade();
$facade->generateApiMarkdownFile();
23 changes: 11 additions & 12 deletions build/src/ApiGenerator/Application/ApiSearchGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
private const array SPECIAL_ENDING_CHARS = ['=', '*', '?', '+', '>', '<', '!'];

public function __construct(
private ApiFacadeInterface $apiFacade
private ApiFacadeInterface $apiFacade,
) {
}

Expand Down Expand Up @@ -62,9 +62,8 @@ public function generateSearchIndex(): array

// Add documentation files to search index
$documentationItems = $this->generateDocumentationSearchItems();
$result = array_merge($result, $documentationItems);

return $result;
return array_merge($result, $documentationItems);
}

/**
Expand All @@ -83,8 +82,8 @@ private function formatDescription(string $desc): string
private function generateDocumentationSearchItems(): array
{
$result = [];
$documentationPath = __DIR__ . '/../../../../../content/documentation';
$documentationPath = __DIR__ . '/../../../../content/documentation';

if (!is_dir($documentationPath)) {
error_log("Documentation path not found: " . $documentationPath);
return [];
Expand All @@ -95,31 +94,31 @@ private function generateDocumentationSearchItems(): array
error_log("Could not scan documentation directory: " . $documentationPath);
return [];
}

foreach ($files as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) !== 'md' || $file === '_index.md') {
continue;
}

$filePath = $documentationPath . '/' . $file;
$content = file_get_contents($filePath);

// Extract title from frontmatter
$title = pathinfo($file, PATHINFO_FILENAME);
if (preg_match('/title = "([^"]+)"/', $content, $matches)) {
$title = $matches[1];
}

// Remove frontmatter
$content = preg_replace('/\+\+\+.*?\+\+\+/s', '', $content);

// Remove markdown formatting and clean content
$content = preg_replace('/[#`*\[\]()]/', ' ', $content);
$content = preg_replace('/\s+/', ' ', trim($content));

// Limit content length for search index
$content = substr($content, 0, 500);

$result[] = [
'id' => 'doc_' . pathinfo($file, PATHINFO_FILENAME),
'title' => $title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ private function shouldSkipLine(string $line): bool
return empty($line)
|| str_starts_with($line, '#')
|| str_starts_with($line, '-')
|| str_starts_with($line, '*');
|| str_starts_with($line, '*')
|| str_starts_with($line, '@');
}

private function truncateDescription(string $description): string
Expand Down
Loading