Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
benchmark: Make sure constructors are parsed correctly for docs. [jdd…
Browse files Browse the repository at this point in the history
…alton]
  • Loading branch information
jdalton committed Jan 12, 2011
1 parent bad1e69 commit 0d8b18d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
* [`Benchmark.Suite#run`](#run)

# Benchmark
## <a name="Benchmark" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L125" title="View in source">Benchmark</a>
## <a name="Benchmark" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L125" title="View in source">Benchmark(name, fn, options)</a>
Benchmark constructor.
<sup><code>[&#9650;][1]</code></sup>

Expand Down Expand Up @@ -630,7 +630,7 @@ Displays relevant benchmark information when coerced to a string.


# Benchmark.Suite
## <a name="Suite" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L178" title="View in source">Benchmark.Suite</a>
## <a name="Suite" href="https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L178" title="View in source">Benchmark.Suite(options)</a>
Suite constructor.
<sup><code>[&#9650;][1]</code></sup>

Expand Down
16 changes: 7 additions & 9 deletions docs/parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ function parse($filepath) {
// parse @member
preg_match("/@member ([^\n]+)/", $entry, $members);
$members = array_pop($members);
if ($members) {
if ($members = array_pop($members)) {
$members = preg_split("/,\s*/", $members);
}
if ($isCtor) {
Expand Down Expand Up @@ -78,8 +77,7 @@ function parse($filepath) {
// parse #{call}
preg_match("#\*/\s*(?:function ([^{]*)|(?:". $member ."\.)?([^:=,]*))#", $entry, $call);
$call = array_pop($call);
if ($call) {
if ($call = array_pop($call)) {
$call = trim(trim($call), "'");
}
Expand All @@ -99,16 +97,14 @@ function parse($filepath) {
// parse #{desc}
preg_match("#/\*\*([^@]+)#", $entry, $desc);
$desc = array_pop($desc);
if ($desc) {
if ($desc = array_pop($desc)) {
$desc = preg_replace("/\n\s*\*\s*/", "\n", $desc);
$desc = ($type == "Function" ? "" : "(" . $type . "): ") . trim($desc);
}
// parse @example
preg_match("#@example([\s\S]*)?(?=\*\s\@[a-z]|\*/)#", $entry, $example);
$example = array_pop($example);
if ($example) {
if ($example = array_pop($example)) {
$example = " " . trim(preg_replace("/\n\s*\* ?/", "\n ", $example));
}
Expand Down Expand Up @@ -246,9 +242,11 @@ function parse($filepath) {
// description
if ($entry["name"]) {
if ($type == "ctor") {
// clip "call"
$entry["call"] = substr($entry["call"], strpos($entry["call"], "("));
$result[] = interpolate(
"## <a name=\"#{hash}\" href=\"#{link}\" title=\"View in source\">" .
"#{member}</a>\n#{desc}\n<sup><code>[&#9650;][1]</code></sup>", $entry);
"#{member}#{call}</a>\n#{desc}\n<sup><code>[&#9650;][1]</code></sup>", $entry);
} else {
$result[] = interpolate(
"## <a name=\"#{hash}\" href=\"#{link}\" title=\"View in source\">" .
Expand Down

0 comments on commit 0d8b18d

Please sign in to comment.