|
| 1 | +use crate::config::Config; |
1 | 2 | use crate::doctest;
|
2 | 3 | use crate::parser;
|
3 | 4 |
|
@@ -47,6 +48,7 @@ pub fn process_markdown(
|
47 | 48 | input: &str,
|
48 | 49 | index: &HashMap<String, String>,
|
49 | 50 | doctests: &mut Vec<doctest::Doctest>,
|
| 51 | + config: &Config, |
50 | 52 | ) -> Page {
|
51 | 53 | let mut code = String::new();
|
52 | 54 | let mut in_code_block = false;
|
@@ -146,7 +148,9 @@ pub fn process_markdown(
|
146 | 148 | let real = get_path_for_name(url, index);
|
147 | 149 |
|
148 | 150 | if let Some(real) = real {
|
149 |
| - return Some(Event::Html(format!("<a href=\"/{}.html\">", real).into())); |
| 151 | + return Some(Event::Html( |
| 152 | + format!("<a href=\"{}/{}.html\">", config.output.base_url, real).into(), |
| 153 | + )); |
150 | 154 | }
|
151 | 155 | }
|
152 | 156 | }
|
@@ -177,66 +181,74 @@ pub fn process_function(
|
177 | 181 | func: &mut parser::Function,
|
178 | 182 | index: &HashMap<String, String>,
|
179 | 183 | doctests: &mut Vec<doctest::Doctest>,
|
| 184 | + config: &Config, |
180 | 185 | ) {
|
181 | 186 | if let Some(ref mut comment) = &mut func.comment {
|
182 |
| - comment.brief = process_markdown(&comment.brief, index, doctests).content; |
183 |
| - comment.description = process_markdown(&comment.description, index, doctests).content; |
| 187 | + comment.brief = process_markdown(&comment.brief, index, doctests, config).content; |
| 188 | + comment.description = |
| 189 | + process_markdown(&comment.description, index, doctests, config).content; |
184 | 190 | }
|
185 | 191 | }
|
186 | 192 |
|
187 | 193 | pub fn process_enum(
|
188 | 194 | enm: &mut parser::Enum,
|
189 | 195 | index: &HashMap<String, String>,
|
190 | 196 | doctests: &mut Vec<doctest::Doctest>,
|
| 197 | + config: &Config, |
191 | 198 | ) {
|
192 | 199 | if let Some(ref mut comment) = &mut enm.comment {
|
193 |
| - comment.brief = process_markdown(&comment.brief, index, doctests).content; |
194 |
| - comment.description = process_markdown(&comment.description, index, doctests).content; |
| 200 | + comment.brief = process_markdown(&comment.brief, index, doctests, config).content; |
| 201 | + comment.description = |
| 202 | + process_markdown(&comment.description, index, doctests, config).content; |
195 | 203 | }
|
196 | 204 | }
|
197 | 205 |
|
198 | 206 | pub fn process_record(
|
199 | 207 | record: &mut parser::Record,
|
200 | 208 | index: &HashMap<String, String>,
|
201 | 209 | doctests: &mut Vec<doctest::Doctest>,
|
| 210 | + config: &Config, |
202 | 211 | ) {
|
203 | 212 | if let Some(ref mut comment) = &mut record.comment {
|
204 |
| - comment.brief = process_markdown(&comment.brief, index, doctests).content; |
205 |
| - comment.description = process_markdown(&comment.description, index, doctests).content; |
| 213 | + comment.brief = process_markdown(&comment.brief, index, doctests, config).content; |
| 214 | + comment.description = |
| 215 | + process_markdown(&comment.description, index, doctests, config).content; |
206 | 216 | }
|
207 | 217 |
|
208 | 218 | for method in &mut record.methods {
|
209 |
| - process_function(method, index, doctests); |
| 219 | + process_function(method, index, doctests, config); |
210 | 220 | }
|
211 | 221 |
|
212 | 222 | for ctor in &mut record.ctor {
|
213 |
| - process_function(ctor, index, doctests); |
| 223 | + process_function(ctor, index, doctests, config); |
214 | 224 | }
|
215 | 225 | }
|
216 | 226 |
|
217 | 227 | pub fn process_namespace(
|
218 | 228 | namespace: &mut parser::Namespace,
|
219 | 229 | index: &HashMap<String, String>,
|
220 | 230 | doctests: &mut Vec<doctest::Doctest>,
|
| 231 | + config: &Config, |
221 | 232 | ) {
|
222 | 233 | if let Some(ref mut comment) = &mut namespace.comment {
|
223 |
| - comment.brief = process_markdown(&comment.brief, index, doctests).content; |
224 |
| - comment.description = process_markdown(&comment.description, index, doctests).content; |
| 234 | + comment.brief = process_markdown(&comment.brief, index, doctests, config).content; |
| 235 | + comment.description = |
| 236 | + process_markdown(&comment.description, index, doctests, config).content; |
225 | 237 | }
|
226 | 238 |
|
227 | 239 | for func in &mut namespace.functions {
|
228 |
| - process_function(func, index, doctests); |
| 240 | + process_function(func, index, doctests, config); |
229 | 241 | }
|
230 | 242 |
|
231 | 243 | for record in &mut namespace.records {
|
232 |
| - process_record(record, index, doctests); |
| 244 | + process_record(record, index, doctests, config); |
233 | 245 | }
|
234 | 246 |
|
235 | 247 | for enm in &mut namespace.enums {
|
236 |
| - process_enum(enm, index, doctests); |
| 248 | + process_enum(enm, index, doctests, config); |
237 | 249 | }
|
238 | 250 |
|
239 | 251 | for ns in &mut namespace.namespaces {
|
240 |
| - process_namespace(ns, index, doctests); |
| 252 | + process_namespace(ns, index, doctests, config); |
241 | 253 | }
|
242 | 254 | }
|
0 commit comments