Skip to content

Commit cc68dc8

Browse files
committed
feat: finish the implementation of source_dir
1 parent 99e9605 commit cc68dc8

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Doctum.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ public function __construct($iterator = null, array $config = [])
204204
}
205205

206206
$this->version = self::$defaultVersionName;
207-
$this->build_dir = getcwd() . '/build';
208-
$this->cache_dir = getcwd() . '/cache';
207+
$this->build_dir = getcwd() . DIRECTORY_SEPARATOR . 'build';
208+
$this->cache_dir = getcwd() . DIRECTORY_SEPARATOR . 'cache';
209+
$this->source_dir = getcwd() . DIRECTORY_SEPARATOR;
209210

210211
foreach ($config as $key => $value) {
211212
$this->{$key} = $value;
@@ -238,7 +239,9 @@ public function setVersion(string $version): void
238239

239240
public function getProject(): Project
240241
{
241-
return $this->offsetGet('project');
242+
$project = $this->offsetGet('project');
243+
$project->setSourceDir($this->source_dir);
244+
return $project;
242245
}
243246

244247
/**
@@ -372,7 +375,6 @@ private function getBuiltProject(): Project
372375
'theme' => $this->theme,
373376
'title' => $this->title,
374377
'source_url' => $this->source_url,
375-
'source_dir' => $this->source_dir,
376378
'insert_todos' => $this->insert_todos,
377379
'sort_class_properties' => $this->sort_class_properties,
378380
'sort_class_methods' => $this->sort_class_methods,

src/Project.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class Project
5353
protected $version;
5454
protected $filesystem;
5555
protected $interfaces;
56+
/** @var string */
57+
protected $sourceDir;
5658

5759
public function __construct(StoreInterface $store, VersionCollection $versions = null, array $config = [])
5860
{
@@ -90,6 +92,16 @@ public function setParser(Parser $parser): void
9092
$this->parser = $parser;
9193
}
9294

95+
public function setSourceDir(string $sourceDir): void
96+
{
97+
$this->sourceDir = $sourceDir;
98+
}
99+
100+
public function getSourceDir(): string
101+
{
102+
return $this->replaceVars($this->sourceDir);
103+
}
104+
93105
public function getConfig($name, $default = null)
94106
{
95107
return $this->config[$name] ?? $default;

0 commit comments

Comments
 (0)