This is an example of a an .md file, used for adding more rich text documentation in a project or module.
This is a link to the main V site.
This is a bold text.
This is a script <script>console.log('hi from README.md');</script>
.
import os
+Description
This is an example of a an .md file, used for adding more rich text documentation in a project or module.
This is a link to the main V site.
This is a bold text.
This is a script <script>console.log('hi from README.md');</script>
.
Examples
Functions that return different literals:
Example of a function returning boolean:
fn is_odd(x int) bool {
+ if x % 2 == 0 {
+ return false
+ }
+ return true
+}
Another example of a function returning a string:
fn answer() string {
+ return '42'
+}
This example shows a function returning a string with interpolation:
fn str_with_interplation() string {
+ return 'this string has ${42:6} interpolation in it.'
+}
Processing command line args
import os
fn main() {
dump(os.args)
diff --git a/cmd/tools/vdoc/testdata/output_formats/main.text b/cmd/tools/vdoc/testdata/output_formats/main.text
index 21579c4da7..9332bcffe9 100644
--- a/cmd/tools/vdoc/testdata/output_formats/main.text
+++ b/cmd/tools/vdoc/testdata/output_formats/main.text
@@ -11,6 +11,32 @@ module main
## Examples
+ ### Functions that return different literals:
+
+ Example of a function returning boolean:
+ ```v
+ fn is_odd(x int) bool {
+ if x % 2 == 0 {
+ return false
+ }
+ return true
+ }
+ ```
+
+ Another example of a function returning a string:
+ ```v
+ fn answer() string {
+ return '42'
+ }
+ ```
+
+ This example shows a function returning a string with interpolation:
+ ```v
+ fn str_with_interplation() string {
+ return 'this string has ${42:6} interpolation in it.'
+ }
+ ```
+
### Processing command line args
```v
diff --git a/cmd/tools/vdoc/testdata/readme_in_project_root/README.md b/cmd/tools/vdoc/testdata/readme_in_project_root/README.md
index 0bc2274399..7a2a2c6ab1 100644
--- a/cmd/tools/vdoc/testdata/readme_in_project_root/README.md
+++ b/cmd/tools/vdoc/testdata/readme_in_project_root/README.md
@@ -1 +1,18 @@
hello from readme
+
+Example:
+```v
+fn is_odd(x int) bool {
+ if x % 2 == 0 {
+ return false
+ }
+ return true
+}
+```
+
+Another example:
+```v
+fn answer() string {
+ return '42'
+}
+```
diff --git a/cmd/tools/vdoc/testdata/readme_in_project_root/src/main.readme.comments.out b/cmd/tools/vdoc/testdata/readme_in_project_root/src/main.readme.comments.out
index e426e3ec2f..f6e2f15335 100644
--- a/cmd/tools/vdoc/testdata/readme_in_project_root/src/main.readme.comments.out
+++ b/cmd/tools/vdoc/testdata/readme_in_project_root/src/main.readme.comments.out
@@ -1,4 +1,16 @@
hello from readme
+Example:
+fn is_odd(x int) bool {
+ if x % 2 == 0 {
+ return false
+ }
+ return true
+}
+
+Another example:
+fn answer() string {
+ return '42'
+}
module foo
fn bar()
diff --git a/vlib/regex/README.md b/vlib/regex/README.md
index a9ce7b94b3..0c43671817 100644
--- a/vlib/regex/README.md
+++ b/vlib/regex/README.md
@@ -531,7 +531,7 @@ pub fn new() RE
After an initializer is used, the regex expression must be compiled with:
```v ignore
-// compile_opt compile RE pattern string, returning an error if the compilation fails
+// compile_opt compile RE pattern string, returning an error if the compilation fails
pub fn (mut re RE) compile_opt(pattern string) !
```