Skip to content

Commit f02f314

Browse files
committed
Updated mkdocs export to keep desc consistent
1 parent 8a2241b commit f02f314

File tree

9 files changed

+166
-335
lines changed

9 files changed

+166
-335
lines changed

doc-templates/roster-templates-mkdocs/css/roster-style.css

Lines changed: 110 additions & 331 deletions
Large diffs are not rendered by default.

doc-templates/roster-templates-mkdocs/snippets/classInterface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
!!! signature trait "{$interfaceName}"
1+
!!! signature interface "{$interfaceName}"
22
namespace
33
: {$interfaceNamespace}
44

doc-templates/roster-templates-mkdocs/snippets/method.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
description
99
: {$methodReturnDesc}{$hasDesc}
1010

11-
{$methodDescription}{hasDesc$}{$hasExample}
11+
**{$className}{$connector}{$methodName} Description**
12+
13+
{$methodDescription}{hasDesc$}{$hasExample}
1214

1315
!!! example "Example"
1416
{$methodExample}{hasExample$}
17+
18+
---

doc-templates/roster-templates-mkdocs/snippets/staticMethod.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
description
99
: {$methodReturnDesc}{$hasDesc}
1010

11-
{$methodDescription}{hasDesc$}{$hasExample}
11+
**{$className}{$connector}{$methodName} Description**
12+
13+
{$methodDescription}{hasDesc$}{$hasExample}
1214

1315
!!! example "Example"
1416
{$methodExample}{hasExample$}
17+
18+
---

src/Samsara/Roster/Processors/InterfaceInlineProcessor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public function compile(): string
2525

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

28+
if (TemplateFactory::getMkDocs()) {
29+
$description = str_replace(PHP_EOL, PHP_EOL.' ', $description);
30+
}
31+
2832
$this->templateProcessor->supplyReplacement('interfaceName', $this->interface->getShortName());
2933
$this->templateProcessor->supplyReplacement('interfaceNamespace', $this->interface->getNamespaceName());
3034
$this->templateProcessor->supplyReplacement('interfaceDesc', $description);

src/Samsara/Roster/Processors/MethodArgumentDetailProcessor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public function compile(): string
5050
$desc = $this->tags[$tagAccessor]->description;
5151
}
5252

53+
if (TemplateFactory::getMkDocs()) {
54+
$desc = str_replace(PHP_EOL, PHP_EOL.' ', $desc);
55+
}
56+
5357
$template->supplyReplacement('argDesc', $desc);
5458

5559
$argTypeDoc = '';

src/Samsara/Roster/Processors/MethodProcessor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ public function compile(): string
5252
}
5353

5454
if (!empty($this->docBlock->description)) {
55+
if (TemplateFactory::getMkDocs()) {
56+
$methodDesc = str_replace(PHP_EOL, PHP_EOL.' ', $this->docBlock->description);
57+
} else {
58+
$methodDesc = $this->docBlock->description;
59+
}
60+
5561
$this->templateProcessor->markHas('Desc');
56-
$this->templateProcessor->supplyReplacement('methodDescription', $this->docBlock->description);
62+
$this->templateProcessor->supplyReplacement('methodDescription', $methodDesc);
5763
}
5864

5965
$returnType = (string)$this->method->getReturnType();

src/Samsara/Roster/Processors/TraitInlineProcessor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public function compile(): string
2626

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

29+
if (TemplateFactory::getMkDocs()) {
30+
$description = str_replace(PHP_EOL, PHP_EOL.' ', $description);
31+
}
32+
2933
$this->templateProcessor->supplyReplacement('traitName', $this->trait->getShortName());
3034
$this->templateProcessor->supplyReplacement('traitNamespace', $this->trait->getNamespaceName());
3135
$this->templateProcessor->supplyReplacement('traitDesc', $description);
@@ -54,6 +58,10 @@ public function compile(): string
5458
$methodDoc = new DocBlockProcessor($method->getDocComment());
5559
$originalMethodDesc = (empty($methodDoc->description) ? '*No description available*' : $methodDoc->description);
5660

61+
if (TemplateFactory::getMkDocs()) {
62+
$originalMethodDesc = str_replace(PHP_EOL, PHP_EOL.' ', $originalMethodDesc);
63+
}
64+
5765
$aliasTemplate->supplyReplacement('originalMethod', $original);
5866
$aliasTemplate->supplyReplacement('newMethod', $alias);
5967
$aliasTemplate->supplyReplacement('originalMethodDesc', $originalMethodDesc);

src/Samsara/Roster/TemplateFactory.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class TemplateFactory
2121
private static array $writtenFiles = [];
2222
private static bool $preferSource = true;
2323
private static int $visibilityLevel = 1;
24+
private static bool $mkdocs = false;
25+
private static string $theme = 'sphinx';
2426

2527
public static function setPreferSource(bool $preferSource)
2628
{
@@ -32,6 +34,26 @@ public static function getPreferSource(): bool
3234
return self::$preferSource;
3335
}
3436

37+
public static function setMkDocs(bool $mkdocs)
38+
{
39+
self::$mkdocs = $mkdocs;
40+
}
41+
42+
public static function getMkDocs(): bool
43+
{
44+
return self::$mkdocs;
45+
}
46+
47+
public static function setTheme(bool $theme)
48+
{
49+
self::$theme = $theme;
50+
}
51+
52+
public static function getTheme(): string
53+
{
54+
return self::$theme;
55+
}
56+
3557
public static function setVisibilityLevel(int $visibilityLevel)
3658
{
3759
self::$visibilityLevel = $visibilityLevel;

0 commit comments

Comments
 (0)