Skip to content

Commit 03e37e7

Browse files
authored
fix: parse github emoji (geocoder-php#19)
fix: parse github emoji
2 parents f7fc552 + 2b33da7 commit 03e37e7

16 files changed

+366
-33467
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/build_local/
22
/build_staging/
33
/build_production/
4-
/build_staging/
54
/node_modules/
65
/vendor/
76
.DS_Store
7+
.cache/

bootstrap.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

3+
use App\Extend\DocumentationImporter;
4+
use App\Extend\GithubEmojiReplacer;
35
use App\Listeners\GenerateSitemap;
6+
use GuzzleHttp\Client;
47
use Mni\FrontYAML\Markdown\MarkdownParser;
58
use TightenCo\Jigsaw\Jigsaw;
69
use TightenCo\Jigsaw\Parsers\ParsedownExtraParser;
@@ -19,7 +22,7 @@
1922
* });
2023
*/
2124

22-
$events->beforeBuild(\App\Extend\DocumentationImporter::class);
25+
$events->beforeBuild(DocumentationImporter::class);
2326
$events->afterCollections(\App\Extend\UpdateProviderNavigation::class);
2427

2528
$events->afterBuild(GenerateSitemap::class);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"tightenco/jigsaw": "^1.3",
44
"tightenco/jigsaw-docs-template": "^1.0",
55
"samdark/sitemap": "^2.2",
6-
"symfony/process": "^4.3"
6+
"symfony/process": "^4.3",
7+
"guzzlehttp/guzzle": "^6.3"
78
},
89
"autoload": {
910
"psr-4": {

composer.lock

Lines changed: 278 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extend/DocumentationImporter.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace App\Extend;
55

6+
use GuzzleHttp\Client;
67
use Symfony\Component\Process\Process;
78
use TightenCo\Jigsaw\Jigsaw;
89

@@ -11,9 +12,17 @@ class DocumentationImporter
1112
const GIT_REPO_URL = 'https://github.com/geocoder-php/Geocoder.git';
1213
const CLONE_LOCATION = '/tmp/geocoder-build';
1314

15+
/** @var GithubEmojiReplacer */
16+
private $emojiReplacer;
17+
18+
public function __construct()
19+
{
20+
$this->emojiReplacer = new GithubEmojiReplacer(new Client());
21+
}
22+
1423
public function handle(Jigsaw $jigsaw)
1524
{
16-
if ($jigsaw->getEnvironment() !== 'production') {
25+
if ($jigsaw->getEnvironment() !== 'production' && file_exists($jigsaw->getSourcePath() . '/docs/index.md')) {
1726
return;
1827
}
1928

@@ -52,6 +61,8 @@ public function updateMainDocumentation(Jigsaw $jigsaw)
5261
'Geocoder'
5362
);
5463

64+
$content = $this->emojiReplacer->replace($content);
65+
5566
$jigsaw->writeSourceFile('docs/index.md', $content);
5667
}
5768

@@ -68,8 +79,9 @@ public function updateProvidersDocumentation(Jigsaw $jigsaw)
6879

6980
foreach ($providerReadmeFiles as $fileName) {
7081
$provider = basename(dirname($fileName));
82+
$file = $this->emojiReplacer->replace(file_get_contents($fileName));
7183

72-
$jigsaw->writeSourceFile(sprintf('docs/providers/%s.md', $provider), $this->withHeader(file_get_contents($fileName), $provider));
84+
$jigsaw->writeSourceFile(sprintf('docs/providers/%s.md', $provider), $this->withHeader($file, $provider));
7385
}
7486
}
7587

0 commit comments

Comments
 (0)