From c3356476f9fccb7e83c1ca3c51c0c8d6dae63baa Mon Sep 17 00:00:00 2001 From: Cat Stevens Date: Wed, 30 May 2018 19:19:41 -0400 Subject: [PATCH] finish up fixes to help.lint.coverage --- extra/help/lint/coverage/coverage-docs.factor | 10 +-- .../help/lint/coverage/coverage-tests.factor | 9 +-- extra/help/lint/coverage/coverage.factor | 67 ++++++++++++------- 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/extra/help/lint/coverage/coverage-docs.factor b/extra/help/lint/coverage/coverage-docs.factor index 3aac96ac49..60e0b6984f 100644 --- a/extra/help/lint/coverage/coverage-docs.factor +++ b/extra/help/lint/coverage/coverage-docs.factor @@ -108,11 +108,11 @@ HELP: prefix-help-coverage. [english] pluralize: full help coverage [english] singular?: full help coverage [english] singularize: full help coverage -[english.private] $0-plurality: needs help sections: $description $examples -[english.private] $keep-case: needs help sections: $description $examples -[english.private] match-case: needs help sections: $description $examples -[english.private] plural-to-singular: needs help sections: $description $examples -[english.private] singular-to-plural: needs help sections: $description $examples +[english.private] $0-plurality: needs help sections: $description and $examples +[english.private] $keep-case: needs help sections: $description and $examples +[english.private] match-case: needs help sections: $description and $examples +[english.private] plural-to-singular: needs help sections: $description and $examples +[english.private] singular-to-plural: needs help sections: $description and $examples 70.6% of words have complete documentation" } diff --git a/extra/help/lint/coverage/coverage-tests.factor b/extra/help/lint/coverage/coverage-tests.factor index 075fda7846..4c668b3889 100644 --- a/extra/help/lint/coverage/coverage-tests.factor +++ b/extra/help/lint/coverage/coverage-tests.factor @@ -1,6 +1,7 @@ -USING: accessors help.lint.coverage help.lint.coverage.private -help.markup help.syntax kernel literals math math.matrices -sequences sorting tools.test vocabs ; +USING: accessors english help.lint.coverage +help.lint.coverage.private help.markup help.syntax kernel +literals math math.matrices sequences sorting tools.test vocabs +; IN: help.lint.coverage.tests ] unit-test { - V{ "needs help " "sections: " { { "$description" $description } { "$examples" $examples } } } + V{ "needs help " "sections: " { { "$description" $description } " and " { "$examples" $examples } } } } [ V{ } clone word-help-coverage new { $description $examples } >>omitted-sections (assemble-omitted-sections) ] unit-test diff --git a/extra/help/lint/coverage/coverage.factor b/extra/help/lint/coverage/coverage.factor index b83fd15b11..27c5641d7c 100644 --- a/extra/help/lint/coverage/coverage.factor +++ b/extra/help/lint/coverage/coverage.factor @@ -4,7 +4,9 @@ fry generic help help.lint help.lint.checks help.markup io io.streams.string io.styles kernel math namespaces parser prettyprint sequences sequences.deep sets sorting splitting strings summary vocabs vocabs.parser words words.alias ; + FROM: namespaces => set ; + IN: help.lint.coverage TUPLE: word-help-coverage @@ -14,6 +16,10 @@ TUPLE: word-help-coverage { 100%-coverage? boolean initial: f } ; > [ length "section" ?pluralize ": " append ] [ - [ [ name>> ] keep 2array ] map + [ [ name>> ] keep 2array ] map "and" comma-list ] bi [ "needs help " ] 2dip 3array over push-all ; @@ -89,15 +93,21 @@ M: word-help-coverage summary loaded-child-vocab-names natural-sort ; inline : filter-private ( seq -- no-private ) - [ ".private" ?tail nip not ] filter ; inline + [ ".private" ?tail nip ] reject ; inline -: ?pluralize ( n singular -- singular/plural ) - count-of-things " " split1 nip ; +: ?remove-$values ( word spec -- spec ) + \ $values over member? [ + swap "declared-effect" word-prop [ + [ in>> ] [ out>> ] bi append [ + \ $values swap remove + ] [ drop ] if-empty + ] when* ] [ nip ] if ; : should-define ( word -- spec ) - { + dup { ! predicates have generated docs { [ dup predicate? ] [ drop { } ] } + { [ dup primitive? ] [ drop { $description } ] } ! aliases should describe why they exist but ideally $values should be ! automatically inherited from the aliased word's docs { [ dup alias? ] [ drop { $values $description } ] } @@ -105,8 +115,7 @@ M: word-help-coverage summary { [ dup class? ] [ drop { $class-description } ] } { [ dup generic? ] [ drop { $values $contract $examples } ] } { [ dup word? ] [ drop { $values $description $examples } ] } - [ drop no-cond ] - } cond ; + } cond ?remove-$values ; : word-defines-sections ( word -- seq ) word-help [ ignored-words member? not ] filter [ ?first ] map ; @@ -118,6 +127,10 @@ M: word-help-coverage summary : missing-sections ( word -- missing ) [ should-define ] [ word-defines-sections ] bi diff ; + +GENERIC: loaded-vocab? ( vocab-spec -- ? ) +M: string loaded-vocab? lookup-vocab >boolean ; +M: vocab loaded-vocab? source-loaded?>> +done+ = ; PRIVATE> GENERIC: ( word -- coverage ) @@ -130,15 +143,22 @@ M: string find-word ; inline : ( vocab-spec -- coverage ) - [ auto-use? off vocab-words natural-sort [ ] map ] with-scope ; + dup loaded-vocab? [ + [ auto-use? off vocab-words natural-sort [ ] map ] with-scope + ] [ + unloaded-vocab + ] if ; : ( prefix private? -- coverage ) - [ - auto-use? off group-articles vocab-articles set - [ sorted-loaded-child-vocabs ] dip not - [ filter-private ] when - [ ] map flatten - ] with-scope ; + over loaded-vocab? [ + [ auto-use? off group-articles vocab-articles set + [ sorted-loaded-child-vocabs ] dip not + [ filter-private ] when + [ ] map flatten + ] with-scope + ] [ + drop unloaded-vocab + ] if ; GENERIC: help-coverage. ( coverage -- ) M: sequence help-coverage. @@ -157,4 +177,3 @@ M: word-help-coverage help-coverage. : word-help-coverage. ( word-spec -- ) help-coverage. ; : vocab-help-coverage. ( vocab-spec -- ) help-coverage. ; : prefix-help-coverage. ( prefix-spec private? -- ) help-coverage. ; -