From 9560c67fb0a971dfe8eb1fd5f8df51ace860477d Mon Sep 17 00:00:00 2001 From: Pavel Janda Date: Sun, 28 Jan 2018 23:16:21 +0100 Subject: [PATCH] Added new macro (MacroInlineFileLink) to link external files to documentations output directory --- README.md | 11 +++- docs-src/about.md | 2 + docs/about.html | 2 +- docs/assets/favicon.ico | Bin 0 -> 4286 bytes src/Markdown/Macros/MacroInlineFileLink.php | 55 ++++++++++++++++++++ src/Markdown/Parser.php | 2 + 6 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 docs/assets/favicon.ico create mode 100644 src/Markdown/Macros/MacroInlineFileLink.php diff --git a/README.md b/README.md index f05e6e5..7a6fee2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ublaboo/anabelle ## Api documentation generator (JSON-RPC / REST) -(No matter whether you're using REST or JSON-RPC) +(No matter whether you're using REST or JSON-RPC or some other api architecture/scheme) ### Example @@ -76,6 +76,15 @@ Method section definition. This macro available only in `index.md` file. @@ user.confirm-registration:methods/user.confirm-registration.md ``` +#### `[File link](foo/bar/data.json)` + +[File link](foo/bar/data.json) will create a link to file (`foo/bar/data.json`). The file will be copied to documentation output directory for safety reasons. + +```md +[File link](foo/bar/data.json) +[Project root directory file link](../app/schema/user.json) +``` + ## How to use anabelle diff --git a/docs-src/about.md b/docs-src/about.md index c7e6171..c4eea67 100644 --- a/docs-src/about.md +++ b/docs-src/about.md @@ -1,3 +1,5 @@ ## About Blah blah blah about + +[This](../assets/favicon.ico) is a link to a file (`assets/favicon.ico`) that will be copied do documentations directory. It can be used for example for linking project-related json files, config YAML files and other important data. diff --git a/docs/about.html b/docs/about.html index a26fef9..fb76b25 100644 --- a/docs/about.html +++ b/docs/about.html @@ -1 +1 @@ -

About

Blah blah blah about

\ No newline at end of file +

About

Blah blah blah about

This is a link to a file (assets/favicon.ico) that will be copied do documentations directory. It can be used for example for linking project-related json files, config YAML files and other important data.

\ No newline at end of file diff --git a/docs/assets/favicon.ico b/docs/assets/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..542c49563d7bb2c143585636af3c61aaa38e9197 GIT binary patch literal 4286 zcmc(j>rWFw5Wv?@e)W@I;iG?mQ4>uh#+U#;P>E;)2%;bc0b`*AlhSBP&{%>zj1nXe zLqv%h1w-(K_&_iOgAl1$umlvSh|04qt>ez=u6u>^F6~*53^(2G&TnpZhP{E174#=O zoZxR#zlxC6gpf5<=n#pZg5z4Q#K^SGD> zSz*kN5VM(Yoyezbj5!+%^_}f^sJV=X`LL+<`Lp7q;M}PUsI52)DZ4f@8^PQ$Cx58% zbC2wWmrq*2=ko!(7Ut(*#9@c$kM2RS`2-~I*dX(x>qRS@3YqbdvhM_*YK>V7vccna zb6ZNv7w0%sms%hxdcDLNc-zCL2FgDcw-sh*rnw!j*9#pq4rLZ2n2skvL1v<)x3%2i z^Bi^?c@UK^waXYx52cy?%^1+g$ z4?p9;HgLOL+=tfYTadK9_GT5JJ#Lww<+0p zp!qNEsi+^0*(99%)DBs!osU-U)PF-AElyP=`>qKJpI*a*d3 z5!dUbU#q&n`M6iX+SO8XBE#1An)B`by+QFYrdV^h&xS)Ws&ICCjkTd#pDO!@>lOQN2O%rX^j`!h%#VM4XFLaG{{-RX BsmlNW literal 0 HcmV?d00001 diff --git a/src/Markdown/Macros/MacroInlineFileLink.php b/src/Markdown/Macros/MacroInlineFileLink.php new file mode 100644 index 0000000..2443327 --- /dev/null +++ b/src/Markdown/Macros/MacroInlineFileLink.php @@ -0,0 +1,55 @@ +href($targetPath) + ->setText($text) + ->target('_blank'); + } + + return "[$text]($path)"; + }, + $content + ); + } +} diff --git a/src/Markdown/Parser.php b/src/Markdown/Parser.php index c75eab0..7d7a853 100644 --- a/src/Markdown/Parser.php +++ b/src/Markdown/Parser.php @@ -14,6 +14,7 @@ use Ublaboo\Anabelle\Markdown\Macros\MacroBlockVariableOutput; use Ublaboo\Anabelle\Markdown\Macros\MacroCleanIndex; use Ublaboo\Anabelle\Markdown\Macros\MacroInclude; +use Ublaboo\Anabelle\Markdown\Macros\MacroInlineFileLink; use Ublaboo\Anabelle\Markdown\Macros\MacroInlineVariable; use Ublaboo\Anabelle\Markdown\Macros\MacroInlineVariableOutput; use Ublaboo\Anabelle\Markdown\Macros\MacroSection; @@ -120,6 +121,7 @@ private function setupMacros(): void $this->macros[] = new MacroInclude; $this->macros[] = new MacroInlineVariable($this->docuScope); $this->macros[] = new MacroInlineVariableOutput($this->docuScope); + $this->macros[] = new MacroInlineFileLink($this->docuScope); $this->macros[] = new MacroBlockVariable($this->docuScope); $this->macros[] = new MacroBlockVariableOutput($this->docuScope);