LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Godoc comment extraction and comment -> HTML formatting. | 5 // Godoc comment extraction and comment -> HTML formatting. |
6 | 6 |
7 package doc | 7 package doc |
8 | 8 |
9 import ( | 9 import ( |
10 "go/ast" | 10 "go/ast" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 | 282 |
283 // Convert comment text to formatted HTML. | 283 // Convert comment text to formatted HTML. |
284 // The comment was prepared by DocReader, | 284 // The comment was prepared by DocReader, |
285 // so it is known not to have leading, trailing blank lines | 285 // so it is known not to have leading, trailing blank lines |
286 // nor to have trailing spaces at the end of lines. | 286 // nor to have trailing spaces at the end of lines. |
287 // The comment markers have already been removed. | 287 // The comment markers have already been removed. |
288 // | 288 // |
289 // Turn each run of multiple \n into </p><p> | 289 // Turn each run of multiple \n into </p><p>. |
290 // Turn each run of indented lines into a <pre> block without indent. | 290 // Turn each run of indented lines into a <pre> block without indent. |
291 // | 291 // |
292 // URLs in the comment text are converted into links; if the URL also appears | 292 // URLs in the comment text are converted into links; if the URL also appears |
293 // in the words map, the link is taken from the map (if the corresponding map | 293 // in the words map, the link is taken from the map (if the corresponding map |
294 // value is the empty string, the URL is not converted into a link). | 294 // value is the empty string, the URL is not converted into a link). |
295 // | 295 // |
296 // Go identifiers that appear in the words map are italicized; if the correspond
ing | 296 // Go identifiers that appear in the words map are italicized; if the correspond
ing |
297 // map value is not the empty string, it is considered a URL and the word is con
verted | 297 // map value is not the empty string, it is considered a URL and the word is con
verted |
298 // into a link. | 298 // into a link. |
299 func ToHTML(w io.Writer, s []byte, words map[string]string) { | 299 func ToHTML(w io.Writer, s []byte, words map[string]string) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 w.Write(html_endpre) | 348 w.Write(html_endpre) |
349 continue | 349 continue |
350 } | 350 } |
351 // open paragraph | 351 // open paragraph |
352 open() | 352 open() |
353 emphasize(w, lines[i], words, true) // nice text formatting | 353 emphasize(w, lines[i], words, true) // nice text formatting |
354 i++ | 354 i++ |
355 } | 355 } |
356 close() | 356 close() |
357 } | 357 } |
LEFT | RIGHT |