1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vdoc: markdown, html, json generation + lots of fixes

This commit is contained in:
Ned Palacios
2020-06-02 18:10:01 +08:00
committed by GitHub
parent 46dbbd0ed0
commit b99ba21ddd
7 changed files with 772 additions and 153 deletions

472
cmd/tools/vdoc.v Normal file

File diff suppressed because one or more lines are too long

View File

@@ -18,6 +18,7 @@ V supports the following commands:
test Run all test files in the provided directory.
fmt Format the V code provided.
doc Generate the documentation for a V module.
vlib-docs Generate and open the documentation of all the vlib modules.
repl Run the REPL.
* Installation/self updating:
symlink Create a symbolic link for V.
@@ -37,4 +38,4 @@ Use "v help <command>" for more information about a command, example: `v help bu
Use "v help other" to see less frequently used commands.
Note: Help is required to write more help topics.
Only build, fmt, run, test, search, install, remove, update, bin2v are properly documented currently.
Only build, doc, fmt, run, test, search, install, remove, update, bin2v are properly documented currently.

16
cmd/v/help/doc.txt Normal file
View File

@@ -0,0 +1,16 @@
Usage:
v doc [flags] module_name output_file[.json|.md|.html]
v doc [flags] path_to_source.v output_file[.json|.md|.html]
v doc [flags] ./directory output_file[.json|.md|.html]
v doc [flags] . output_file[.json|.md|.html]
Generates the documentation of a given directory, module, or V source file
and prints or saves them to its desired format. It can generate HTML, JSON,
or Markdown format.
Options:
-all Includes private and public functions/methods/structs/consts/enums.
-loc Show the locations of the generated signatures. (For plaintext only)
-m Generate docs for modules listed in that folder.
-s Serve HTML-generated docs via HTTP.
-r Include README.md to docs if present.

View File

@@ -5,8 +5,6 @@ module main
import help
import os
import v.table
import v.doc
import v.pref
import v.util
import v.builder
@@ -19,7 +17,7 @@ const (
'repl',
'build-tools', 'build-examples',
'build-vbinaries',
'setup-freetype'
'setup-freetype', 'doc'
]
list_of_flags_that_allow_duplicates = ['cc', 'd', 'define', 'cf', 'cflags']
)
@@ -80,6 +78,9 @@ fn main_v() {
util.launch_tool(prefs.is_verbose, 'vpm', os.args[1..])
return
}
'vlib-docs' {
util.launch_tool(prefs.is_verbose, 'vdoc', ['doc', '-m', '-s', '-r', os.join_path(os.base_dir(@VEXE), 'vlib')])
}
'get' {
println('V Error: Use `v install` to install modules from vpm.vlang.io')
exit(1)
@@ -88,17 +89,6 @@ fn main_v() {
println(util.full_v_version(prefs.is_verbose))
return
}
'doc' {
mut mod := ''
if args.len == 1 {
println('v doc [module]')
} else if args.len > 1 {
mod = args[1]
}
table := table.new_table()
println(doc.doc(mod, table, prefs))
return
}
else {}
}
if command in ['run', 'build-module'] || command.ends_with('.v') || os.exists(command) {