Browse Source

detailed page template

tags/0.1.0
Robin Thoni 8 years ago
parent
commit
5c18562cbe
2 changed files with 214 additions and 10 deletions
  1. 27
    10
      src/Doc/Business/LuDocBusiness.php
  2. 187
    0
      src/Doc/Templates/method.html.twig

+ 27
- 10
src/Doc/Business/LuDocBusiness.php View File

@@ -71,6 +71,16 @@ class LuDocBusiness
71 71
         return str_replace("-", "\\", $business);
72 72
     }
73 73
 
74
+    private static function printTwig($file, $vars)
75
+    {
76
+        $loader = new Twig_Loader_Filesystem(__DIR__ . "/../Templates");
77
+        $twig = new Twig_Environment($loader, array());
78
+        $template = $twig->loadTemplate($file . ".twig");
79
+        $content = $template->render($vars);
80
+        echo $content;
81
+        exit;
82
+    }
83
+
74 84
     /**
75 85
      * Print the help page
76 86
      */
@@ -109,12 +119,7 @@ class LuDocBusiness
109 119
             $businesses_tiwg[] = $business_tiwg;
110 120
         }
111 121
 
112
-        $loader = new Twig_Loader_Filesystem(__DIR__ . "/../Templates");
113
-        $twig = new Twig_Environment($loader, array());
114
-        $template = $twig->loadTemplate("index.html.twig");
115
-        $content = $template->render(array("businesses" => $businesses_tiwg));
116
-        echo $content;
117
-        exit;
122
+        self::printTwig("index.html", array("businesses" => $businesses_tiwg));
118 123
     }
119 124
 
120 125
     /**
@@ -138,10 +143,22 @@ class LuDocBusiness
138 143
                 $business = $b;
139 144
             }
140 145
         }
141
-        echo "<h1>" . $business->getMethod() . " " . $business->getUrl() . "</h1>";
142 146
 
143
-        $reflection = new ReflectionMethod($businessName, $method);
144
-        echo str_replace("\n", "<br />", $reflection->getDocComment());
145
-        exit;
147
+        $reflection = new ReflectionMethod($business->getBusinessClass(), $business->getBusinessMethod());
148
+        $description = $reflection->getDocComment();
149
+        if ($description === false) {
150
+            $description = "No description available";
151
+        }
152
+        else {
153
+            $docParser = new DocBlock($description);
154
+            $description = $docParser->description;
155
+        }
156
+
157
+
158
+        self::printTwig("method.html", array(
159
+            "description" => $description,
160
+            "url" => $business->getUrl(),
161
+            "method" => $business->getMethod(),
162
+            "parameters" => []));
146 163
     }
147 164
 }

+ 187
- 0
src/Doc/Templates/method.html.twig View File

@@ -0,0 +1,187 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+    <meta charset="utf-8" />
5
+    <meta name="viewport" content="width=device-width" />
6
+    <title>{{ method }} {{ url }}</title>
7
+
8
+    <style>
9
+        .help-page h1,
10
+        .help-page .h1,
11
+        .help-page h2,
12
+        .help-page .h2,
13
+        .help-page h3,
14
+        .help-page .h3,
15
+        #body.help-page,
16
+        .help-page-table th,
17
+        .help-page-table pre,
18
+        .help-page-table p {
19
+            font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
20
+        }
21
+
22
+        .help-page pre.wrapped {
23
+            white-space: -moz-pre-wrap;
24
+            white-space: -pre-wrap;
25
+            white-space: -o-pre-wrap;
26
+            white-space: pre-wrap;
27
+        }
28
+
29
+        .help-page .warning-message-container {
30
+            margin-top: 20px;
31
+            padding: 0 10px;
32
+            color: #525252;
33
+            background: #EFDCA9;
34
+            border: 1px solid #CCCCCC;
35
+        }
36
+
37
+        .help-page-table {
38
+            width: 100%;
39
+            border-collapse: collapse;
40
+            text-align: left;
41
+            margin: 0 0 20px 0;
42
+            border-top: 1px solid #D4D4D4;
43
+        }
44
+
45
+        .help-page-table th {
46
+            text-align: left;
47
+            font-weight: bold;
48
+            border-bottom: 1px solid #D4D4D4;
49
+            padding: 5px 6px 5px 6px;
50
+        }
51
+
52
+        .help-page-table td {
53
+            border-bottom: 1px solid #D4D4D4;
54
+            padding: 10px 8px 10px 8px;
55
+            vertical-align: top;
56
+        }
57
+
58
+        .help-page-table pre,
59
+        .help-page-table p {
60
+            margin: 0;
61
+            padding: 0;
62
+            font-family: inherit;
63
+            font-size: 100%;
64
+        }
65
+
66
+        .help-page-table tbody tr:hover td {
67
+            background-color: #F3F3F3;
68
+        }
69
+
70
+        .help-page a:hover {
71
+            background-color: transparent;
72
+        }
73
+
74
+        .help-page .sample-header {
75
+            border: 2px solid #D4D4D4;
76
+            background: #00497E;
77
+            color: #FFFFFF;
78
+            padding: 8px 15px;
79
+            border-bottom: none;
80
+            display: inline-block;
81
+            margin: 10px 0 0 0;
82
+        }
83
+
84
+        .help-page .sample-content {
85
+            display: block;
86
+            border-width: 0;
87
+            padding: 15px 20px;
88
+            background: #FFFFFF;
89
+            border: 2px solid #D4D4D4;
90
+            margin: 0 0 10px 0;
91
+        }
92
+
93
+        .help-page .api-name {
94
+            width: 40%;
95
+        }
96
+
97
+        .help-page .api-documentation {
98
+            width: 60%;
99
+        }
100
+
101
+        .help-page .parameter-name {
102
+            width: 20%;
103
+        }
104
+
105
+        .help-page .parameter-documentation {
106
+            width: 40%;
107
+        }
108
+
109
+        .help-page .parameter-type {
110
+            width: 20%;
111
+        }
112
+
113
+        .help-page .parameter-annotations {
114
+            width: 20%;
115
+        }
116
+
117
+        .help-page h1,
118
+        .help-page .h1 {
119
+            font-size: 36px;
120
+            line-height: normal;
121
+        }
122
+
123
+        .help-page h2,
124
+        .help-page .h2 {
125
+            font-size: 24px;
126
+        }
127
+
128
+        .help-page h3,
129
+        .help-page .h3 {
130
+            font-size: 20px;
131
+        }
132
+
133
+        #body.help-page {
134
+            font-size: 14px;
135
+            line-height: 143%;
136
+            color: #333;
137
+        }
138
+
139
+        .help-page a {
140
+            color: #0000EE;
141
+            text-decoration: none;
142
+        }
143
+    </style>
144
+</head>
145
+<body>
146
+
147
+<div id="body" class="help-page">
148
+    <section class="featured">
149
+        <div class="content-wrapper">
150
+            <p>
151
+                <a href="../..">Help Page Home</a>
152
+            </p>
153
+        </div>
154
+    </section>
155
+    <section class="content-wrapper main-content clear-fix">
156
+
157
+        <h1>{{ method }} {{ url }}</h1>
158
+        <p>{{ description }}</p>
159
+        <h3>Parameters</h3>
160
+
161
+        <table class="help-page-table">
162
+            <thead>
163
+            <tr><th>Name</th><th>Description</th><th>Type</th><th>Additional information</th></tr>
164
+            </thead>
165
+            <tbody>
166
+            {% for param in parameters %}
167
+            <tr>
168
+                <td class="parameter-name">{{ param.name }}</td>
169
+                <td class="parameter-documentation">
170
+                    <p>{{ param.description }}</p>
171
+                </td>
172
+                <td class="parameter-type">
173
+                    {{ param.type }}
174
+                </td>
175
+                <td class="parameter-annotations">
176
+                    <p>{{ param.annotations }}</p>
177
+                </td>
178
+            </tr>
179
+            {% endfor %}
180
+            </tbody>
181
+        </table>
182
+
183
+
184
+    </section>
185
+</div>
186
+</body>
187
+</html>

Loading…
Cancel
Save