From a87cd9663ec41ff327f6e1371a2a0ec280ef78e2 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Thu, 31 Mar 2022 17:32:32 +0100 Subject: [PATCH] vdoc: highlight inline examples for `-f html` (#13879) --- cmd/tools/vdoc/html.v | 4 ++-- vlib/builtin/array.v | 2 +- vlib/builtin/int.v | 2 +- vlib/builtin/js/byte.js.v | 2 +- vlib/builtin/option.v | 4 ++-- vlib/vweb/vweb.v | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/tools/vdoc/html.v b/cmd/tools/vdoc/html.v index 3e96338ad4..70cbf879aa 100644 --- a/cmd/tools/vdoc/html.v +++ b/cmd/tools/vdoc/html.v @@ -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('

$example_title

') for example in examples { - // hl_example := html_highlight(example, tb) - dnw.writeln('
$example
') + hl_example := html_highlight(example, tb) + dnw.writeln('
$hl_example
') } dnw.writeln('
') } diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 2d7b712fb9..8531c8f288 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -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, diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index 8549145d65..efd93a47ad 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -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` diff --git a/vlib/builtin/js/byte.js.v b/vlib/builtin/js/byte.js.v index 48e18e46ed..1e03b13118 100644 --- a/vlib/builtin/js/byte.js.v +++ b/vlib/builtin/js/byte.js.v @@ -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` diff --git a/vlib/builtin/option.v b/vlib/builtin/option.v index 40a9f376b0..230a8ea85a 100644 --- a/vlib/builtin/option.v +++ b/vlib/builtin/option.v @@ -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') diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 03551e9dcb..69f3b998a6 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -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(global_app &T, params RunParams) ? { mut l := net.listen_tcp(params.family, '$params.host:$params.port') or {