1
0
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:
Nick Treleaven 2022-03-31 17:32:32 +01:00 committed by GitHub
parent 5c43493183
commit a87cd9663e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 9 deletions

View File

@ -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' } example_title := if examples.len > 1 { 'Examples' } else { 'Example' }
dnw.writeln('<section class="doc-node examples"><h4>$example_title</h4>') dnw.writeln('<section class="doc-node examples"><h4>$example_title</h4>')
for example in examples { for example in examples {
// hl_example := html_highlight(example, tb) hl_example := html_highlight(example, tb)
dnw.writeln('<pre><code class="language-v">$example</code></pre>') dnw.writeln('<pre><code class="language-v">$hl_example</code></pre>')
} }
dnw.writeln('</section>') dnw.writeln('</section>')
} }

View File

@ -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'` // 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 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 // Ignore the function signature. `all` does not take an actual callback. Rather, it
// takes an `it` expression. // takes an `it` expression.
// It returns `false` if any element fails the test. Otherwise, // It returns `false` if any element fails the test. Otherwise,

View File

@ -516,7 +516,7 @@ pub fn (b byte) str_escaped() string {
// is_capital returns `true`, if the byte is a Latin capital letter. // is_capital returns `true`, if the byte is a Latin capital letter.
// Example: assert `H`.is_capital() == true // Example: assert `H`.is_capital() == true
// Example: assert 'h`.is_capital() == false // Example: assert `h`.is_capital() == false
[inline] [inline]
pub fn (c byte) is_capital() bool { pub fn (c byte) is_capital() bool {
return c >= `A` && c <= `Z` return c >= `A` && c <= `Z`

View File

@ -72,7 +72,7 @@ pub fn (c byte) is_alnum() bool {
// is_capital returns `true`, if the byte is a Latin capital letter. // is_capital returns `true`, if the byte is a Latin capital letter.
// Example: assert `H`.is_capital() == true // Example: assert `H`.is_capital() == true
// Example: assert 'h`.is_capital() == false // Example: assert `h`.is_capital() == false
[inline] [inline]
pub fn (c byte) is_capital() bool { pub fn (c byte) is_capital() bool {
return c >= `A` && c <= `Z` return c >= `A` && c <= `Z`

View File

@ -85,7 +85,7 @@ fn trace_error(x string) {
} }
// error returns a default error instance containing the error given in `message`. // 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] [inline]
pub fn error(message string) IError { pub fn error(message string) IError {
trace_error(message) 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`. // 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] [inline]
pub fn error_with_code(message string, code int) IError { pub fn error_with_code(message string, code int) IError {
trace_error('$message | code: $code') trace_error('$message | code: $code')

View File

@ -157,7 +157,7 @@ pub mut:
static_files map[string]string static_files map[string]string
static_mime_types map[string]string static_mime_types map[string]string
// Map containing query params for the route. // 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 query map[string]string
// Multipart-form fields. // Multipart-form fields.
form map[string]string 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` // 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] [manualfree]
pub fn run_at<T>(global_app &T, params RunParams) ? { pub fn run_at<T>(global_app &T, params RunParams) ? {
mut l := net.listen_tcp(params.family, '$params.host:$params.port') or { mut l := net.listen_tcp(params.family, '$params.host:$params.port') or {