Skip to content

Commit

Permalink
ci: make the report-missing-fn-doc step a bit more sensitive, and ver…
Browse files Browse the repository at this point in the history
…bose in its diagnostic output for missing comments on deprecated methods/fns
  • Loading branch information
spytheman committed Nov 19, 2023
1 parent cc220e6 commit 4b347a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/docs_ci.yml
Expand Up @@ -15,7 +15,10 @@ on:
jobs:
check-markdown:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
if: >
github.event_name != 'push'
|| github.event.ref == 'refs/heads/master'
|| github.event.repository.full_name != 'vlang/v'
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
Expand All @@ -28,10 +31,13 @@ jobs:

report-missing-fn-doc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
if: >
github.event_name != 'push'
|| github.event.ref == 'refs/heads/master'
|| github.event.repository.full_name != 'vlang/v'
timeout-minutes: 5
env:
MOPTIONS: --relative-paths --exclude /vlib/v/ --exclude /builtin/linux_bare/ --exclude /testdata/ --exclude /tests/
MOPTIONS: --diff --deprecated --relative-paths --exclude /vlib/v/ --exclude /builtin/linux_bare/ --exclude /testdata/ --exclude /tests/
steps:
- uses: actions/checkout@v3
- name: Build V
Expand All @@ -46,4 +52,4 @@ jobs:

- name: Check against parent commit
run: |
./v missdoc --diff $MOPTIONS pv/vlib vlib
./v missdoc $MOPTIONS pv/vlib vlib
15 changes: 9 additions & 6 deletions cmd/tools/vmissdoc.v
Expand Up @@ -103,12 +103,12 @@ fn (opt &Options) collect_undocumented_functions_in_path(path string) []Undocume
}

fn (opt &Options) report_undocumented_functions_in_path(path string) int {
mut list := opt.collect_undocumented_functions_in_path(path)
opt.report_undocumented_functions(list)
return list.len
list := opt.collect_undocumented_functions_in_path(path)
return opt.report_undocumented_functions(list)
}

fn (opt &Options) report_undocumented_functions(list []UndocumentedFN) {
fn (opt &Options) report_undocumented_functions(list []UndocumentedFN) int {
mut nreports := 0
if list.len > 0 {
for undocumented_fn in list {
mut line_numbers := '${undocumented_fn.line}:0:'
Expand All @@ -128,6 +128,7 @@ fn (opt &Options) report_undocumented_functions(list []UndocumentedFN) {
}
if opt.deprecated {
println('${ofile}:${line_numbers}${undocumented_fn.signature} ${tags_str}')
nreports++
} else {
mut has_deprecation_tag := false
for tag in undocumented_fn.tags {
Expand All @@ -138,10 +139,12 @@ fn (opt &Options) report_undocumented_functions(list []UndocumentedFN) {
}
if !has_deprecation_tag {
println('${ofile}:${line_numbers}${undocumented_fn.signature} ${tags_str}')
nreports++
}
}
}
}
return nreports
}

fn (opt &Options) diff_undocumented_functions_in_paths(path_old string, path_new string) []UndocumentedFN {
Expand Down Expand Up @@ -275,8 +278,8 @@ fn main() {
exit(1)
}
list := opt.diff_undocumented_functions_in_paths(path_old, path_new)
if list.len > 0 {
opt.report_undocumented_functions(list)
nreports := opt.report_undocumented_functions(list)
if nreports > 0 {
exit(1)
}
exit(0)
Expand Down

0 comments on commit 4b347a8

Please sign in to comment.