From 08340544d9d90f9da074433a7bfbb04069bda79c Mon Sep 17 00:00:00 2001 From: james Date: Mon, 27 Sep 2010 20:38:49 +0000 Subject: [PATCH] Add api documentation --- api.php | 14 ++++++------ apidoc.css | 25 +++++++++++++++++++++ apidoc.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 apidoc.css create mode 100644 apidoc.php diff --git a/api.php b/api.php index 3540f579..40e9d0c6 100644 --- a/api.php +++ b/api.php @@ -38,7 +38,7 @@ $ret=array(); switch($request[0]) { case "conferences": - /* apidoc: conferences/switch + /* APIDOC: conferences/switch description(switches the active conference) post(conferences_id integer) return(conferences_id integer) @@ -60,7 +60,7 @@ switch($request[0]) { $ret['error']='conferences_id (integer) is required'; } } - /* apidoc: conferences + /* APIDOC: conferences description(lists all conferences) return(conferences array) */ @@ -78,11 +78,11 @@ switch($request[0]) { break; case "dates": - /* apidoc: dates + /* APIDOC: dates description(list dates for active conference) return(dates array) */ - /* apidoc: dates/ + /* APIDOC: dates/ description(list dates for specified conference) return(dates array) */ @@ -104,7 +104,7 @@ switch($request[0]) { break; case "account": - /* apidoc: account/create + /* APIDOC: account/create description(creates an account) post(username varchar(64), password varchar(64), email varchar(64) optional) return(account array) @@ -143,7 +143,7 @@ switch($request[0]) { break; case "auth": - /* apidoc: auth/login + /* APIDOC: auth/login description(login to an account) post(username varchar(64), password varchar(64)) return(account array, roles array, conferences_id integer) @@ -174,7 +174,7 @@ switch($request[0]) { $ret['roles']=$_SESSION['roles']; } } - /* apidoc: auth/logout + /* APIDOC: auth/logout description(logs out of an account) return(account array) */ diff --git a/apidoc.css b/apidoc.css new file mode 100644 index 00000000..fe1a4df4 --- /dev/null +++ b/apidoc.css @@ -0,0 +1,25 @@ +body { + font-size: 0.9em; +} +h1 { + font-size: 1.2em; + font-weight: bold; +} +h2 { + font-size: 1.0em; + font-weight: bold; + margin-bottom: 0px; +} +.apidoc { + margin-left: 50px; +} + +ul { + margin: 0px; + padding-top: 0px; + font-size: 0.9em; +} + +li { + margin-top: 0px; +} diff --git a/apidoc.php b/apidoc.php new file mode 100644 index 00000000..fe7ee9e2 --- /dev/null +++ b/apidoc.php @@ -0,0 +1,64 @@ + + +API Doc + + + +$com) { + echo "

".htmlspecialchars($c)."

"; + echo "
\n"; + echo $com['description']; + echo "
"; + if(count($com['post'])) { + echo "

POST

\n"; + echo "
    "; + foreach($com['post'] AS $p) { + echo "
  • $p
  • \n"; + } + echo "
"; + } + if(count($com['return'])) { + echo "

RETURN

\n"; + echo "
    "; + foreach($com['return'] AS $p) { + echo "
  • $p
  • \n"; + } + echo "
"; + } + echo "
"; + echo "
"; +} +?> +