Skip to content

Commit

Permalink
docdown: Initial commit. [jddalton]
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jun 2, 2011
0 parents commit 9733fbc
Show file tree
Hide file tree
Showing 9 changed files with 765 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* eol=lf
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
20 changes: 20 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,20 @@
Copyright John-David Dalton <http://allyoucanleet.com/>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
@@ -0,0 +1,46 @@
# DocDown

A simple JSDoc to Markdown documentation generator.

## Documentation

The documentation for Docdown can be viewed here: [/docs/README.md](https://github.com/jdalton/docdown/blob/master/docs/README.md#readme)

For a list of upcoming features, check out our [roadmap](https://github.com/jdalton/docdown/wiki/Roadmap).

## Installation and usage

Usage example:

~~~ php

require("docdown.php");

// generate Markdown
$markdown = docdown(array(
"path" => $filepath,
"url" => "https://github.com/username/project/blob/master/my.js"
));

~~~

## Cloning this repo

To clone this repository including all submodules, using git 1.6.5 or later:

~~~ bash
git clone https://github.com/docdown/docdown.git
cd docdown
~~~

Feel free to fork if you see possible improvements!

## Authors

* [John-David Dalton](http://allyoucanleet.com/)
[![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter")

## Contributors

* [Mathias Bynens](http://mathiasbynens.be/)
[![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter")
19 changes: 19 additions & 0 deletions docdown.php
@@ -0,0 +1,19 @@
<?php
/*!
* This file is part of the DocDown package.
* Copyright 2011 John-David Dalton <http://allyoucanleet.com/>
* Available under MIT license <http://mths.be/mit>
*/

require(dirname(__FILE__) . "/src/DocDown/Generator.php");

/**
* Generates Markdown from JSDoc entries in a given file.
* @param {Array} $options The options array.
* @returns {String} The generated Markdown.
*/
function docdown( $options = array() ) {
$gen = new Generator($options);
return $gen->generate();
}
?>
45 changes: 45 additions & 0 deletions docs/README.md
@@ -0,0 +1,45 @@
# Docdown.php API documentation

<!-- div -->


<!-- div -->

## `docdown`
* [`docdown`](#docdown)

<!-- /div -->


<!-- /div -->


<!-- div -->


<!-- div -->

## `docdown`

<!-- div -->

### <a id="docdown" href="" title="View in source">`docdown($options)`</a>
Generates Markdown from JSDoc entries in a given file.
[&#9650;][1]

#### Arguments
1. `$options` *(Array)*: The options array.

#### Returns
*(String)*: The generated Markdown.

<!-- /div -->


<!-- /div -->


<!-- /div -->


[1]: #readme "Jump back to the TOC."
28 changes: 28 additions & 0 deletions docs/parse.php
@@ -0,0 +1,28 @@
<?php

// cleanup requested filepath
$_GET["f"] = isset($_GET["f"]) ? $_GET["f"] : "docdown";
$_GET["f"] = preg_replace("#(\.*[\/])+#", "", $_GET["f"]);
$_GET["f"] = $_GET["f"] . (preg_match("/\.[a-z]+$/", $_GET["f"]) ? "" : ".php");

// output filename
$_GET["o"] = isset($_GET["o"]) ? $_GET["o"] : basename($_GET["f"]);

/*--------------------------------------------------------------------------*/

require("../docdown.php");

// generate Markdown
$markdown = docdown(array(
"path" => "../" . $_GET["f"],
"url" => "https://github.com/jdalton/docdown/blob/master/docdown.php"
));

// save to a .md file
file_put_contents($_GET["o"] . ".md", $markdown);

// print
header("Content-Type: text/plain;charset=utf-8");
echo $markdown . PHP_EOL;

?>

0 comments on commit 9733fbc

Please sign in to comment.