mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vdoc: highlight inline examples for -f html
(#13879)
This commit is contained in:
parent
5c43493183
commit
a87cd9663e
@ -430,8 +430,8 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
|
||||
example_title := if examples.len > 1 { 'Examples' } else { 'Example' }
|
||||
dnw.writeln('<section class="doc-node examples"><h4>$example_title</h4>')
|
||||
for example in examples {
|
||||
// hl_example := html_highlight(example, tb)
|
||||
dnw.writeln('<pre><code class="language-v">$example</code></pre>')
|
||||
hl_example := html_highlight(example, tb)
|
||||
dnw.writeln('<pre><code class="language-v">$hl_example</code></pre>')
|
||||
}
|
||||
dnw.writeln('</section>')
|
||||
}
|
||||
|
@ -690,7 +690,7 @@ pub fn (a array) filter(predicate fn (voidptr) bool) array
|
||||
// Example: array.any(it.name == 'Bob') // will yield `true` if any element has `.name == 'Bob'`
|
||||
pub fn (a array) any(predicate fn (voidptr) bool) bool
|
||||
|
||||
// all tests whether all elements in the array pass the test
|
||||
// all tests whether all elements in the array pass the test.
|
||||
// Ignore the function signature. `all` does not take an actual callback. Rather, it
|
||||
// takes an `it` expression.
|
||||
// It returns `false` if any element fails the test. Otherwise,
|
||||
|
@ -516,7 +516,7 @@ pub fn (b byte) str_escaped() string {
|
||||
|
||||
// is_capital returns `true`, if the byte is a Latin capital letter.
|
||||
// Example: assert `H`.is_capital() == true
|
||||
// Example: assert 'h`.is_capital() == false
|
||||
// Example: assert `h`.is_capital() == false
|
||||
[inline]
|
||||
pub fn (c byte) is_capital() bool {
|
||||
return c >= `A` && c <= `Z`
|
||||
|
@ -72,7 +72,7 @@ pub fn (c byte) is_alnum() bool {
|
||||
|
||||
// is_capital returns `true`, if the byte is a Latin capital letter.
|
||||
// Example: assert `H`.is_capital() == true
|
||||
// Example: assert 'h`.is_capital() == false
|
||||
// Example: assert `h`.is_capital() == false
|
||||
[inline]
|
||||
pub fn (c byte) is_capital() bool {
|
||||
return c >= `A` && c <= `Z`
|
||||
|
@ -85,7 +85,7 @@ fn trace_error(x string) {
|
||||
}
|
||||
|
||||
// error returns a default error instance containing the error given in `message`.
|
||||
// Example: `if ouch { return error('an error occurred') }`
|
||||
// Example: if ouch { return error('an error occurred') }
|
||||
[inline]
|
||||
pub fn error(message string) IError {
|
||||
trace_error(message)
|
||||
@ -95,7 +95,7 @@ pub fn error(message string) IError {
|
||||
}
|
||||
|
||||
// error_with_code returns a default error instance containing the given `message` and error `code`.
|
||||
// `if ouch { return error_with_code('an error occurred', 1) }`
|
||||
// Example: if ouch { return error_with_code('an error occurred', 1) }
|
||||
[inline]
|
||||
pub fn error_with_code(message string, code int) IError {
|
||||
trace_error('$message | code: $code')
|
||||
|
@ -157,7 +157,7 @@ pub mut:
|
||||
static_files map[string]string
|
||||
static_mime_types map[string]string
|
||||
// Map containing query params for the route.
|
||||
// Example: `http://localhost:3000/index?q=vpm&order_by=desc => { 'q': 'vpm', 'order_by': 'desc' }
|
||||
// http://localhost:3000/index?q=vpm&order_by=desc => { 'q': 'vpm', 'order_by': 'desc' }
|
||||
query map[string]string
|
||||
// Multipart-form fields.
|
||||
form map[string]string
|
||||
@ -389,7 +389,7 @@ pub struct RunParams {
|
||||
}
|
||||
|
||||
// run_at - start a new VWeb server, listening only on a specific address `host`, at the specified `port`
|
||||
// Example: `vweb.run_at(app, 'localhost', 8099)`
|
||||
// Example: vweb.run_at(app, 'localhost', 8099)
|
||||
[manualfree]
|
||||
pub fn run_at<T>(global_app &T, params RunParams) ? {
|
||||
mut l := net.listen_tcp(params.family, '$params.host:$params.port') or {
|
||||
|
Loading…
Reference in New Issue
Block a user