Skip to content

Commit

Permalink
tools,v.doc: move vlib/v/doc/ to cmd/tools/vdoc/doc/
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jan 16, 2025
1 parent e5153e7 commit 92fe3c7
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ tests in the main V repository, for example:

> [!NOTE]
The VDOC test vdoc_file_test.v now also supports VAUTOFIX, which is
useful, if you change anything inside cmd/tools/vdoc or vlib/v/doc/,
useful, if you change anything inside cmd/tools/vdoc,
or inside the modules that it depends on (like markdown).
After such changes, just run this command *2 times*, and commit the
resulting changes in `cmd/tools/vdoc/testdata` as well:
Expand Down
File renamed without changes.
30 changes: 15 additions & 15 deletions vlib/v/doc/doc.v → cmd/tools/vdoc/doc/doc.v
Original file line number Diff line number Diff line change
Expand Up @@ -536,28 +536,28 @@ pub fn generate(input_path string, pub_only bool, with_comments bool, platform P
if platform == .js {
return error('vdoc: Platform `${platform}` is not supported.')
}
mut doc := new(input_path)
doc.pub_only = pub_only
doc.with_comments = with_comments
doc.filter_symbol_names = filter_symbol_names.filter(it.len != 0)
doc.prefs.os = if platform == .auto {
mut d := new(input_path)
d.pub_only = pub_only
d.with_comments = with_comments
d.filter_symbol_names = filter_symbol_names.filter(it.len != 0)
d.prefs.os = if platform == .auto {
pref.get_host_os()
} else {
unsafe { pref.OS(int(platform)) }
}
doc.generate()!
return doc
d.generate()!
return d
}

// generate_with_pos has the same function as the `generate` function but
// accepts an offset-based position and enables the comments by default.
pub fn generate_with_pos(input_path string, filename string, pos int) !Doc {
mut doc := new(input_path)
doc.pub_only = false
doc.with_comments = true
doc.with_pos = true
doc.filename = filename
doc.pos = pos
doc.generate()!
return doc
mut d := new(input_path)
d.pub_only = false
d.with_comments = true
d.with_pos = true
d.filename = filename
d.pos = pos
d.generate()!
return d
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ fn test_get_parent_mod_normal_cases() {
assert get_parent_mod(os.join_path(@VMODROOT, 'vlib', 'os', 'os.v'))? == 'os'
assert get_parent_mod(os.join_path(@VMODROOT, 'cmd'))? == ''
assert get_parent_mod(os.join_path(@VMODROOT, 'cmd', 'tools', 'modules', 'testing',
'common.v'))? == 'testing'
'common.v'))? == 'tools.modules.testing'
}
2 changes: 1 addition & 1 deletion vlib/v/doc/doc_test.v → cmd/tools/vdoc/doc/doc_test.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import v.ast
import v.doc
import doc

// fn test_generate_with_pos() {}
// fn test_generate() {}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion vlib/v/doc/utils.v → cmd/tools/vdoc/doc/utils.v
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn merge_doc_comments(comments []DocComment) string {
for key in highlight_keys {
if ll.starts_with(key) {
comment += '\n\n${key.title()}${l[key.len..]}'
// Workaround for compiling with `v -cstrict -cc gcc vlib/v/doc/doc_test.v`
// Workaround for compiling with `v -cstrict -cc gcc cmd/tools/vdoc/doc/doc_test.v`
// and using multiple continue `<label>`.
continue_line_loop = true
break
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import markdown
import v.scanner
import v.ast
import v.token
import v.doc
import doc
import v.pref
import v.util { tabs }

Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module main
import os
import os.cmdline
import term
import v.doc
import doc
import v.vmod

const vexe = os.getenv_opt('VEXE') or { @VEXE }
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/markdown.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module main

import strings
import v.doc
import doc

fn (vd &VDoc) gen_markdown(d doc.Doc, with_toc bool) string {
cfg := vd.cfg
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/run_examples.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module main

import v.doc
import doc
import v.vmod
import strings
import os
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/testdata/basic/basic.comments.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module basic
module testdata.basic

const source_root = 'temp' // some const
const another = int(5)
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/testdata/basic/basic.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module basic
module testdata.basic

const source_root = 'temp' // some const
const another = int(5)
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/utils.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module main

import v.doc
import doc

@[inline]
fn slug(title string) string {
Expand Down
Empty file added cmd/tools/vdoc/v.mod
Empty file.
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/vdoc.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import time
import strings
import sync
import runtime
import v.doc
import doc
import v.vmod
import v.util
import json
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/vtest-self.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const vroot = os.dir(os.real_path(os.getenv_opt('VEXE') or { @VEXE }))

const essential_list = [
'cmd/tools/vvet/vet_test.v',
'cmd/tools/vdoc/doc/doc_test.v',
'vlib/arrays/arrays_test.v',
'vlib/bitfield/bitfield_test.v',
//
Expand Down Expand Up @@ -84,7 +85,6 @@ const essential_list = [
'vlib/time/time_test.v',
'vlib/toml/tests/toml_test.v',
'vlib/v/compiler_errors_test.v',
'vlib/v/doc/doc_test.v',
'vlib/v/eval/interpret_test.v',
'vlib/v/fmt/fmt_keep_test.v',
'vlib/v/fmt/fmt_test.v',
Expand Down Expand Up @@ -114,7 +114,6 @@ const skip_test_files = [
const skip_fsanitize_too_slow = [
'do_not_remove',
'vlib/v/compiler_errors_test.v',
'vlib/v/doc/doc_test.v',
'vlib/v/fmt/fmt_test.v',
'vlib/v/fmt/fmt_keep_test.v',
'vlib/v/fmt/fmt_vlib_test.v',
Expand All @@ -131,6 +130,7 @@ const skip_fsanitize_too_slow = [
'cmd/tools/vpm/install_version_input_test.v',
'cmd/tools/vpm/install_version_test.v',
'cmd/tools/vpm/update_test.v',
'cmd/tools/vdoc/doc/doc_test.v',
]
const skip_with_fsanitize_memory = [
'do_not_remove',
Expand Down

0 comments on commit 92fe3c7

Please sign in to comment.