Skip to content

Commit 433af9b

Browse files
committed
Initial commit
1 parent be3b1f2 commit 433af9b

25 files changed

+5232
-0
lines changed

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff:
7+
.idea/workspace.xml
8+
.idea/tasks.xml
9+
.idea/dictionaries
10+
.idea/vcs.xml
11+
.idea/jsLibraryMappings.xml
12+
13+
# Sensitive or high-churn files:
14+
.idea/dataSources.ids
15+
.idea/dataSources.xml
16+
.idea/dataSources.local.xml
17+
.idea/sqlDataSources.xml
18+
.idea/dynamic.xml
19+
.idea/uiDesigner.xml
20+
21+
# Gradle:
22+
.idea/gradle.xml
23+
.idea/libraries
24+
25+
# Mongo Explorer plugin:
26+
.idea/mongoSettings.xml
27+
28+
## File-based project format:
29+
*.iws
30+
31+
## Plugin-specific files:
32+
33+
# IntelliJ
34+
/out/
35+
36+
# mpeltonen/sbt-idea plugin
37+
.idea_modules/
38+
39+
# JIRA plugin
40+
atlassian-ide-plugin.xml
41+
42+
# Crashlytics plugin (for Android Studio and IntelliJ)
43+
com_crashlytics_export_strings.xml
44+
crashlytics.properties
45+
crashlytics-build.properties
46+
fabric.properties
47+
48+
# Phar creation file
49+
create_phar.php

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# PHP-Drafter
2+
This is a parser for API Blueprint files in PHP.
3+
4+
## Writing API documentation
5+
6+
For writing API documentation using [API Blueprint](http://apiblueprint.org/) syntax. You can read about its [specification](https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md).
7+
8+
Here's the example:
9+
10+
```markdown
11+
FORMAT: 1A
12+
HOST: https://api.example.com/v1
13+
14+
# Hello API
15+
16+
A simple API demo
17+
18+
# Group People
19+
20+
This section describes about the People
21+
22+
## Person [/people/{id}]
23+
24+
Represent particular Person
25+
26+
+ Parameters
27+
28+
+ id (required, string, `123`) ... The id of the Person.
29+
30+
+ Model (application/json)
31+
32+
```
33+
{"name":"Gesang","birthdate":"01-09-1917"}
34+
```
35+
36+
### Retrieve Person [GET]
37+
38+
Return the information for the Person
39+
40+
+ Request (application/json)
41+
42+
+ Headers
43+
44+
```
45+
Authorization: Basic AbcdeFg=
46+
```
47+
48+
+ Response 200 (application/json)
49+
50+
[Person][]
51+
52+
```
53+
54+
## Usage
55+
For direct usage you can run:
56+
```bash
57+
$ ./php-drafter.phar blueprint-file.apib > blueprint-webpage.html
58+
```
59+
You can also install it first:
60+
```bash
61+
$ cp php-drafter.phar /usr/bin/php-drafter
62+
$ chmod +x /usr/bin/php-drafter
63+
$ php-drafter blueprint-file.apib > blueprint-webpage.html
64+
```
65+
66+
## Dependencies
67+
68+
PHP-Drafter requires [drafter](https://github.com/apiaryio/drafter) to be installed. Refer to the drafter page for the installation details.
69+
70+
### Libraries
71+
This app usage the following libraries:
72+
* https://github.com/michelf/php-markdown.git

config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"tmpdir": "/tmp/drafter"
3+
}

create_phar.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* This file contains the create_phar.php
4+
*
5+
* @package php-drafter\SOMETHING
6+
* @author Sean Molenaar<[email protected]>
7+
*/
8+
$phar_file = 'php-drafter.phar';
9+
$shebang = '/usr/bin/php';
10+
//$shebang = system('/usr/bin/env php');
11+
12+
if (file_exists($phar_file)) {
13+
unlink($phar_file);
14+
}
15+
$phar = new Phar($phar_file);
16+
17+
$phar = $phar->convertToExecutable(Phar::PHAR);
18+
19+
// start buffering. Mandatory to modify stub.
20+
$phar->startBuffering();
21+
22+
// Get the default stub. You can create your own if you have specific needs
23+
$defaultStub = $phar->createDefaultStub('index.php');
24+
25+
// Adding files
26+
$phar->buildFromDirectory(__DIR__);
27+
28+
// Create a custom stub to add the shebang
29+
$stub = "#!$shebang \n".$defaultStub;
30+
31+
// Add the stub
32+
$phar->setStub($stub);
33+
34+
$phar->stopBuffering();

index.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
set_include_path(get_include_path().":".__DIR__);
3+
$config = json_decode(file_get_contents(__DIR__."/config.json"));
4+
require_once 'src/PHPDraft/Core/Autoloader.php';
5+
use PHPDraft\In\ApibFileParser;
6+
use PHPDraft\Parse\ApibToJson;
7+
use PHPDraft\Parse\JsonToHTML;
8+
$apib = new ApibFileParser($argv[1]);
9+
$json = new ApibToJson($apib);
10+
$json->parseToJson();
11+
$html = new JsonToHTML($json);
12+
echo $html->get_html();
13+
?>

src/Michelf/Markdown.inc.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
// Use this file if you cannot use class autoloading. It will include all the
4+
// files needed for the Markdown parser.
5+
//
6+
// Take a look at the PSR-0-compatible class autoloading implementation
7+
// in the Readme.php file if you want a simple autoloader setup.
8+
9+
require_once dirname(__FILE__) . '/MarkdownInterface.php';
10+
require_once dirname(__FILE__) . '/Markdown.php';

0 commit comments

Comments
 (0)