From 40b574b409e2ea0c62d9ab57c509b84bf52cecf1 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 16 Jan 2025 14:40:28 +0200 Subject: [PATCH] tools,v.doc: move `vlib/v/doc/` to `cmd/tools/vdoc/doc/` to reduce the runtime of the CI runs, when `v doc` is changed (#23483) --- TESTS.md | 2 +- {vlib/v => cmd/tools/vdoc}/doc/comment.v | 0 {vlib/v => cmd/tools/vdoc}/doc/doc.v | 30 +++++++++---------- .../tools/vdoc}/doc/doc_private_fn_test.v | 2 +- {vlib/v => cmd/tools/vdoc}/doc/doc_test.v | 2 +- {vlib/v => cmd/tools/vdoc}/doc/module.v | 0 {vlib/v => cmd/tools/vdoc}/doc/node.v | 0 {vlib/v => cmd/tools/vdoc}/doc/utils.v | 2 +- cmd/tools/vdoc/html.v | 2 +- cmd/tools/vdoc/main.v | 2 +- cmd/tools/vdoc/markdown.v | 2 +- cmd/tools/vdoc/run_examples.v | 2 +- .../vdoc/testdata/basic/basic.comments.out | 2 +- cmd/tools/vdoc/testdata/basic/basic.out | 2 +- cmd/tools/vdoc/utils.v | 2 +- cmd/tools/vdoc/v.mod | 0 cmd/tools/vdoc/vdoc.v | 2 +- cmd/tools/vtest-self.v | 4 +-- 18 files changed, 29 insertions(+), 29 deletions(-) rename {vlib/v => cmd/tools/vdoc}/doc/comment.v (100%) rename {vlib/v => cmd/tools/vdoc}/doc/doc.v (97%) rename {vlib/v => cmd/tools/vdoc}/doc/doc_private_fn_test.v (96%) rename {vlib/v => cmd/tools/vdoc}/doc/doc_test.v (99%) rename {vlib/v => cmd/tools/vdoc}/doc/module.v (100%) rename {vlib/v => cmd/tools/vdoc}/doc/node.v (100%) rename {vlib/v => cmd/tools/vdoc}/doc/utils.v (98%) create mode 100644 cmd/tools/vdoc/v.mod diff --git a/TESTS.md b/TESTS.md index 97adb67559..bda9c5660d 100644 --- a/TESTS.md +++ b/TESTS.md @@ -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: diff --git a/vlib/v/doc/comment.v b/cmd/tools/vdoc/doc/comment.v similarity index 100% rename from vlib/v/doc/comment.v rename to cmd/tools/vdoc/doc/comment.v diff --git a/vlib/v/doc/doc.v b/cmd/tools/vdoc/doc/doc.v similarity index 97% rename from vlib/v/doc/doc.v rename to cmd/tools/vdoc/doc/doc.v index 5cf27a91b6..a06588d313 100644 --- a/vlib/v/doc/doc.v +++ b/cmd/tools/vdoc/doc/doc.v @@ -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 } diff --git a/vlib/v/doc/doc_private_fn_test.v b/cmd/tools/vdoc/doc/doc_private_fn_test.v similarity index 96% rename from vlib/v/doc/doc_private_fn_test.v rename to cmd/tools/vdoc/doc/doc_private_fn_test.v index 318865c51e..b367c8eb62 100644 --- a/vlib/v/doc/doc_private_fn_test.v +++ b/cmd/tools/vdoc/doc/doc_private_fn_test.v @@ -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' } diff --git a/vlib/v/doc/doc_test.v b/cmd/tools/vdoc/doc/doc_test.v similarity index 99% rename from vlib/v/doc/doc_test.v rename to cmd/tools/vdoc/doc/doc_test.v index c315dfe289..2672d06967 100644 --- a/vlib/v/doc/doc_test.v +++ b/cmd/tools/vdoc/doc/doc_test.v @@ -1,5 +1,5 @@ // import v.ast -import v.doc +import doc // fn test_generate_with_pos() {} // fn test_generate() {} diff --git a/vlib/v/doc/module.v b/cmd/tools/vdoc/doc/module.v similarity index 100% rename from vlib/v/doc/module.v rename to cmd/tools/vdoc/doc/module.v diff --git a/vlib/v/doc/node.v b/cmd/tools/vdoc/doc/node.v similarity index 100% rename from vlib/v/doc/node.v rename to cmd/tools/vdoc/doc/node.v diff --git a/vlib/v/doc/utils.v b/cmd/tools/vdoc/doc/utils.v similarity index 98% rename from vlib/v/doc/utils.v rename to cmd/tools/vdoc/doc/utils.v index 20a73f8b3b..b600765a58 100644 --- a/vlib/v/doc/utils.v +++ b/cmd/tools/vdoc/doc/utils.v @@ -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 `