Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbebf3af

Browse files
authored
Merge pull request#15 from weaverryan/build-system-updates
Various build system updates
2 parents09e7d45 +b4f5b18 commitbebf3af

File tree

17 files changed

+84
-37
lines changed

17 files changed

+84
-37
lines changed

‎_build/src/Command/ParseDoc.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
useDoctrine\RST\Event\PreBuildRenderEvent;
99
useSymfony\Component\Console\Command\Command;
1010
useSymfony\Component\Console\Helper\ProgressBar;
11+
useSymfony\Component\Console\Input\InputArgument;
1112
useSymfony\Component\Console\Input\InputInterface;
1213
useSymfony\Component\Console\Input\InputOption;
1314
useSymfony\Component\Console\Output\OutputInterface;
@@ -54,9 +55,8 @@ protected function configure()
5455
parent::configure();
5556

5657
$this
57-
->addOption('source-dir',null, InputOption::VALUE_REQUIRED,'RST files Source directory',__DIR__.'/../../..')
58-
->addOption('html-output-dir',null, InputOption::VALUE_REQUIRED,'HTML files output directory',__DIR__.'/../../html')
59-
->addOption('json-output-dir',null, InputOption::VALUE_REQUIRED,'JSON files output directory',__DIR__.'/../../json')
58+
->addArgument('source-dir',null, InputArgument::REQUIRED,'RST files Source directory')
59+
->addArgument('output-dir',null, InputArgument::OPTIONAL,'HTML files output directory')
6060
->addOption('parse-only',null, InputOption::VALUE_OPTIONAL,'Parse only given directory for PDF (directory relative from source-dir)',null);
6161
}
6262

@@ -65,17 +65,18 @@ protected function initialize(InputInterface $input, OutputInterface $output)
6565
$this->io =newSymfonyStyle($input,$output);
6666
$this->output =$output;
6767

68-
$this->sourceDir =rtrim($this->getRealAbsolutePath($input->getOption('source-dir')),'/');
68+
$this->sourceDir =rtrim($this->getRealAbsolutePath($input->getArgument('source-dir')),'/');
6969
if (!$this->filesystem->exists($this->sourceDir)) {
7070
thrownew \InvalidArgumentException(sprintf('RST source directory "%s" does not exist',$this->sourceDir));
7171
}
7272

73-
$this->htmlOutputDir =rtrim($this->getRealAbsolutePath($input->getOption('html-output-dir')),'/');
73+
$outputDir =$input->getArgument('output-dir') ??$this->sourceDir .'/html';
74+
$this->htmlOutputDir =rtrim($this->getRealAbsolutePath($outputDir),'/');
7475
if ($this->filesystem->exists($this->htmlOutputDir)) {
7576
$this->filesystem->remove($this->htmlOutputDir);
7677
}
7778

78-
$this->jsonOutputDir =$this->getRealAbsolutePath($input->getOption('json-output-dir'));
79+
$this->jsonOutputDir =$this->getRealAbsolutePath($outputDir.'/json');
7980
if ($this->filesystem->exists($this->jsonOutputDir)) {
8081
$this->filesystem->remove($this->jsonOutputDir);
8182
}
@@ -106,7 +107,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
106107

107108
protectedfunctionexecute(InputInterface$input,OutputInterface$output)
108109
{
109-
$this->finder->in($input->getOption('source-dir'))
110+
$this->finder->in($input->getArgument('source-dir'))
110111
->exclude(['_build','.github','.platform','_images'])
111112
->notName('*.rst.inc')
112113
->name('*.rst');

‎_build/src/Directive/AbstractAdmonitionDirective.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ final public function processSub(Parser $parser, ?Node $document, string $variab
2727
[
2828
'name' =>$this->name,
2929
'text' =>$this->text,
30+
'class' =>null,
3031
]
3132
);
3233

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespaceSymfonyDocs\Directive;
4+
5+
useDoctrine\RST\Directives\SubDirective;
6+
useDoctrine\RST\Nodes\Node;
7+
useDoctrine\RST\Parser;
8+
9+
class AdmonitionDirectiveextends SubDirective
10+
{
11+
publicfunctionprocessSub(Parser$parser, ?Node$document,string$variable,string$data,array$options): ?Node
12+
{
13+
$wrapperDiv =$parser->renderTemplate(
14+
'directives/admonition.html.twig',
15+
[
16+
// a bit strange, but on the old markup we literally
17+
// had a class of 'admonition-"
18+
'name' =>'',
19+
'text' =>$data,
20+
'class' =>isset($options['class']) ?$options['class'] :null,
21+
]
22+
);
23+
24+
return$parser->getNodeFactory()->createWrapperNode($document,$wrapperDiv,'</div></div>');
25+
}
26+
27+
publicfunctiongetName():string
28+
{
29+
return'admonition';
30+
}
31+
}

‎_build/src/KernelFactory.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
useDoctrine\RST\Configuration;
66
useDoctrine\RST\Kernel;
77
useSymfonyDocs\DirectiveasSymfonyDirectives;
8-
useSymfonyDocs\ReferenceasSymfonyRefernces;
8+
useSymfonyDocs\ReferenceasSymfonyReferences;
99

1010
/**
1111
* Class KernelFactory
1212
*/
1313
finalclass KernelFactory
1414
{
15-
publicstaticfunctioncreateKernel(?string$parseOnly):Kernel
15+
publicstaticfunctioncreateKernel(string$parseOnlyPath =null):Kernel
1616
{
1717
$configuration =newConfiguration();
1818
$configuration->setCustomTemplateDirs([__DIR__.'/Templates']);
@@ -24,16 +24,16 @@ public static function createKernel(?string $parseOnly): Kernel
2424
)
2525
);
2626

27-
if ($parseOnly) {
27+
if ($parseOnlyPath) {
2828
$configuration->setBaseUrl(
2929
sprintf(
3030
SymfonyDocConfiguration::getSymfonyDocUrl(),
3131
SymfonyDocConfiguration::getVersion()
3232
)
3333
);
3434
$configuration->setBaseUrlEnabledCallable(
35-
staticfunction (string$path)use ($parseOnly) :bool {
36-
returnstrpos($path,$parseOnly) !==0;
35+
staticfunction (string$path)use ($parseOnlyPath) :bool {
36+
returnstrpos($path,$parseOnlyPath) !==0;
3737
}
3838
);
3939
}
@@ -48,6 +48,7 @@ static function (string $path) use ($parseOnly) : bool {
4848
privatestaticfunctiongetDirectives():array
4949
{
5050
return [
51+
newSymfonyDirectives\AdmonitionDirective(),
5152
newSymfonyDirectives\CautionDirective(),
5253
newSymfonyDirectives\ClassDirective(),
5354
newSymfonyDirectives\CodeBlockDirective(),
@@ -66,14 +67,14 @@ private static function getDirectives(): array
6667
privatestaticfunctiongetReferences():array
6768
{
6869
return [
69-
newSymfonyRefernces\DocReference(),
70-
newSymfonyRefernces\RefReference(),
71-
newSymfonyRefernces\ClassReference(),
72-
newSymfonyRefernces\MethodReference(),
73-
newSymfonyRefernces\NamespaceReference(),
74-
newSymfonyRefernces\PhpFunctionReference(),
75-
newSymfonyRefernces\PhpMethodReference(),
76-
newSymfonyRefernces\PhpClassReference(),
70+
newSymfonyReferences\DocReference(),
71+
newSymfonyReferences\RefReference(),
72+
newSymfonyReferences\ClassReference(),
73+
newSymfonyReferences\MethodReference(),
74+
newSymfonyReferences\NamespaceReference(),
75+
newSymfonyReferences\PhpFunctionReference(),
76+
newSymfonyReferences\PhpMethodReference(),
77+
newSymfonyReferences\PhpClassReference(),
7778
];
7879
}
7980
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<divclass="admonition-{{name }} admonition-wrapper">
2-
<divclass="{{name }}"></div>
1+
<divclass="admonition-wrapper{{class? (''~class):'' }}">
32
<divclass="admonition admonition-{{name }}">
43
<pclass="admonition-title">{{text }}</p>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<divclass="admonition-wrapper"><divclass="sidebar"></div><divclass="admonition admonition-sidebar"><pclass="sidebar-title">{{title|raw }}</p>
1+
<divclass="admonition-wrapper"><divclass="admonition admonition-sidebar"><pclass="sidebar-title">{{title|raw }}</p>

‎_build/tests/IntegrationTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ public function parserUnitBlockProvider()
144144
'blockName' =>'directives/note',
145145
];
146146

147+
yield'admonition' => [
148+
'blockName' =>'directives/admonition',
149+
];
150+
147151
yield'note-code-block-nested' => [
148152
'blockName' =>'directives/note-code-block-nested',
149153
];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<metacharset="utf-8"/>
5+
</head>
6+
<body>
7+
<divclass="admonition-wrapper screencast_class">
8+
<divclass="admonition admonition-">
9+
<pclass="admonition-title">Screencast</p>
10+
<p>Do you prefer video tutorials? Check out the the screencasts.</p>
11+
</div>
12+
</div>
13+
</body>
14+
</html>

‎_build/tests/fixtures/expected/blocks/directives/best-practice.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-best-practice admonition-wrapper">
8-
<divclass="best-practice"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-best-practice">
109
<pclass="admonition-title">Best Practice</p>
1110
<p>Use the bcrypt encoder for hashing your users' passwords.</p>

‎_build/tests/fixtures/expected/blocks/directives/caution.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-caution admonition-wrapper">
8-
<divclass="caution"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-caution">
109
<pclass="admonition-title">Caution</p>
1110
<p>Using too many sidebars or caution directives can be distracting!</p>

‎_build/tests/fixtures/expected/blocks/directives/note-code-block-nested.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-note admonition-wrapper">
8-
<divclass="note"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-note">
109
<pclass="admonition-title">Note</p>
1110
<p>test</p>

‎_build/tests/fixtures/expected/blocks/directives/note.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-note admonition-wrapper">
8-
<divclass="note"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-note">
109
<pclass="admonition-title">Note</p>
1110
<p>Sometimes we add notes. But not too often because they interrupt the flow.</p>

‎_build/tests/fixtures/expected/blocks/directives/seealso.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-seealso admonition-wrapper">
8-
<divclass="seealso"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-seealso">
109
<pclass="admonition-title">See also</p>
1110
<p>Also check out the homepage</p>

‎_build/tests/fixtures/expected/blocks/directives/sidebar-code-block-nested.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
</head>
66
<body>
77
<divclass="admonition-wrapper">
8-
<divclass="sidebar"></div>
98
<divclass="admonition admonition-sidebar">
109
<pclass="sidebar-title">The sidebar's title</p>
1110
<p>some text before code block</p>

‎_build/tests/fixtures/expected/blocks/directives/sidebar.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
</head>
66
<body>
77
<divclass="admonition-wrapper">
8-
<divclass="sidebar"></div>
98
<divclass="admonition admonition-sidebar">
109
<pclass="sidebar-title">The sidebar's title</p>
1110
<p>some text inside sidebar</p>

‎_build/tests/fixtures/expected/blocks/directives/tip.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<metacharset="utf-8"/>
55
</head>
66
<body>
7-
<divclass="admonition-tip admonition-wrapper">
8-
<divclass="tip"></div>
7+
<divclass="admonition-wrapper">
98
<divclass="admonition admonition-tip">
109
<pclass="admonition-title">Tip</p>
1110
<p>This is a little tip about something! We an also talk about specific</p>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
..admonition::Screencast
2+
:class: screencast_class
3+
4+
Do you prefer video tutorials? Check out the the screencasts.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp