Skip to content

Commit

Permalink
Updated mkdocs export to keep desc consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanRL committed Jul 6, 2021
1 parent 8a2241b commit f02f314
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 335 deletions.
441 changes: 110 additions & 331 deletions doc-templates/roster-templates-mkdocs/css/roster-style.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!!! signature trait "{$interfaceName}"
!!! signature interface "{$interfaceName}"
namespace
: {$interfaceNamespace}

Expand Down
6 changes: 5 additions & 1 deletion doc-templates/roster-templates-mkdocs/snippets/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
description
: {$methodReturnDesc}{$hasDesc}

{$methodDescription}{hasDesc$}{$hasExample}
**{$className}{$connector}{$methodName} Description**

{$methodDescription}{hasDesc$}{$hasExample}

!!! example "Example"
{$methodExample}{hasExample$}

---
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
description
: {$methodReturnDesc}{$hasDesc}

{$methodDescription}{hasDesc$}{$hasExample}
**{$className}{$connector}{$methodName} Description**

{$methodDescription}{hasDesc$}{$hasExample}

!!! example "Example"
{$methodExample}{hasExample$}

---
4 changes: 4 additions & 0 deletions src/Samsara/Roster/Processors/InterfaceInlineProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function compile(): string

$description = (empty($this->docBlock->description) ? '*No description available*' : $this->docBlock->description);

if (TemplateFactory::getMkDocs()) {
$description = str_replace(PHP_EOL, PHP_EOL.' ', $description);
}

$this->templateProcessor->supplyReplacement('interfaceName', $this->interface->getShortName());
$this->templateProcessor->supplyReplacement('interfaceNamespace', $this->interface->getNamespaceName());
$this->templateProcessor->supplyReplacement('interfaceDesc', $description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public function compile(): string
$desc = $this->tags[$tagAccessor]->description;
}

if (TemplateFactory::getMkDocs()) {
$desc = str_replace(PHP_EOL, PHP_EOL.' ', $desc);
}

$template->supplyReplacement('argDesc', $desc);

$argTypeDoc = '';
Expand Down
8 changes: 7 additions & 1 deletion src/Samsara/Roster/Processors/MethodProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ public function compile(): string
}

if (!empty($this->docBlock->description)) {
if (TemplateFactory::getMkDocs()) {
$methodDesc = str_replace(PHP_EOL, PHP_EOL.' ', $this->docBlock->description);
} else {
$methodDesc = $this->docBlock->description;
}

$this->templateProcessor->markHas('Desc');
$this->templateProcessor->supplyReplacement('methodDescription', $this->docBlock->description);
$this->templateProcessor->supplyReplacement('methodDescription', $methodDesc);
}

$returnType = (string)$this->method->getReturnType();
Expand Down
8 changes: 8 additions & 0 deletions src/Samsara/Roster/Processors/TraitInlineProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public function compile(): string

$description = (empty($this->docBlock->description) ? '*No description available*' : $this->docBlock->description);

if (TemplateFactory::getMkDocs()) {
$description = str_replace(PHP_EOL, PHP_EOL.' ', $description);
}

$this->templateProcessor->supplyReplacement('traitName', $this->trait->getShortName());
$this->templateProcessor->supplyReplacement('traitNamespace', $this->trait->getNamespaceName());
$this->templateProcessor->supplyReplacement('traitDesc', $description);
Expand Down Expand Up @@ -54,6 +58,10 @@ public function compile(): string
$methodDoc = new DocBlockProcessor($method->getDocComment());
$originalMethodDesc = (empty($methodDoc->description) ? '*No description available*' : $methodDoc->description);

if (TemplateFactory::getMkDocs()) {
$originalMethodDesc = str_replace(PHP_EOL, PHP_EOL.' ', $originalMethodDesc);
}

$aliasTemplate->supplyReplacement('originalMethod', $original);
$aliasTemplate->supplyReplacement('newMethod', $alias);
$aliasTemplate->supplyReplacement('originalMethodDesc', $originalMethodDesc);
Expand Down
22 changes: 22 additions & 0 deletions src/Samsara/Roster/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class TemplateFactory
private static array $writtenFiles = [];
private static bool $preferSource = true;
private static int $visibilityLevel = 1;
private static bool $mkdocs = false;
private static string $theme = 'sphinx';

public static function setPreferSource(bool $preferSource)
{
Expand All @@ -32,6 +34,26 @@ public static function getPreferSource(): bool
return self::$preferSource;
}

public static function setMkDocs(bool $mkdocs)
{
self::$mkdocs = $mkdocs;
}

public static function getMkDocs(): bool
{
return self::$mkdocs;
}

public static function setTheme(bool $theme)
{
self::$theme = $theme;
}

public static function getTheme(): string
{
return self::$theme;
}

public static function setVisibilityLevel(int $visibilityLevel)
{
self::$visibilityLevel = $visibilityLevel;
Expand Down

0 comments on commit f02f314

Please sign in to comment.