OCaml implementation of the Mozilla Public Suffix service
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(lint): resolve E410/E415 doc style issues

Add missing periods to doc comments, fix [name] format mismatches,
and add pp pretty-printer to Publicsuffix.t.

+59 -73
+1
lib/publicsuffix.ml
··· 44 44 45 45 let error_to_string err = Fmt.str "%a" pp_error err 46 46 let create () = { root = Publicsuffix_data.get_root () } 47 + let pp fmt _t = Fmt.pf fmt "<Publicsuffix>" 47 48 48 49 (* Find a child node by label (case-insensitive) *) 49 50 let find_child (node : trie_node) label =
+14 -11
lib/publicsuffix.mli
··· 129 129 | Private (** Domains submitted by private parties *) 130 130 131 131 type t 132 - (** A handle to the parsed Public Suffix List *) 132 + (** A handle to the parsed Public Suffix List. *) 133 + 134 + val pp : Format.formatter -> t -> unit 135 + (** [pp fmt t] pretty-prints a summary of the PSL handle. *) 133 136 134 137 (** {1 Errors} *) 135 138 ··· 158 161 (** The domain is itself a public suffix and has no registrable domain *) 159 162 160 163 val pp_error : Format.formatter -> error -> unit 161 - (** Pretty-print an error *) 164 + (** Pretty-print an error. *) 162 165 163 166 val error_to_string : error -> string 164 - (** Convert an error to a human-readable string *) 167 + (** Convert an error to a human-readable string. *) 165 168 166 169 (** {1 Creation} *) 167 170 ··· 202 205 If the implicit [*] rule was used (no explicit rule matched), the section is 203 206 [ICANN]. 204 207 205 - @return [Ok (suffix, section)] or [Error e] on failure *) 208 + @return [Ok (suffix, section)] or [Error e] on failure. *) 206 209 207 210 val registrable_domain : t -> string -> (string, error) result 208 211 (** [registrable_domain t domain] returns the registrable domain portion. ··· 225 228 Examples: 226 229 - [registrable_domain t "www.example.com"] returns [Ok "example.com"] 227 230 - [registrable_domain t "example.com"] returns [Ok "example.com"] 228 - - [registrable_domain t "com"] returns [Error Domain_is_public_suffix] *) 231 + - [registrable_domain t "com"] returns [Error Domain_is_public_suffix]. *) 229 232 230 233 val registrable_domain_with_section : 231 234 t -> string -> (string * section, error) result 232 235 (** [registrable_domain_with_section t domain] is like {!registrable_domain} but 233 236 also returns the section where the matching rule was found. 234 237 235 - @return [Ok (domain, section)] or [Error e] on failure *) 238 + @return [Ok (domain, section)] or [Error e] on failure. *) 236 239 237 240 (** {1 Predicates} *) 238 241 ··· 255 258 Examples: 256 259 - [is_registrable_domain t "example.com"] returns [Ok true] 257 260 - [is_registrable_domain t "www.example.com"] returns [Ok false] 258 - - [is_registrable_domain t "com"] returns [Ok false] *) 261 + - [is_registrable_domain t "com"] returns [Ok false]. *) 259 262 260 263 (** {1 Statistics} *) 261 264 262 265 val rule_count : t -> int 263 - (** Total number of rules in the embedded PSL *) 266 + (** Total number of rules in the embedded PSL. *) 264 267 265 268 val icann_rule_count : t -> int 266 - (** Number of ICANN section rules *) 269 + (** Number of ICANN section rules. *) 267 270 268 271 val private_rule_count : t -> int 269 - (** Number of private section rules *) 272 + (** Number of private section rules. *) 270 273 271 274 (** {1 Version Information} *) 272 275 ··· 274 277 (** Version string from the embedded PSL data. 275 278 276 279 Returns the version identifier from the Public Suffix List source file, 277 - typically in the format ["YYYY-MM-DD_HH-MM-SS_UTC"]. *) 280 + typically in the format "YYYY-MM-DD_HH-MM-SS_UTC". *) 278 281 279 282 val commit : t -> string 280 283 (** Commit hash from the embedded PSL data.
+1 -1
lib/publicsuffix_data.mli
··· 125 125 The root node represents the starting point for all PSL lookups. Domain 126 126 labels should be traversed in reverse order (TLD first) from this root. 127 127 128 - @return The root trie node containing all PSL rules *) 128 + @return The root trie node containing all PSL rules. *) 129 129 130 130 (** {1 Statistics} 131 131
+1 -1
test/cmd/dune
··· 1 1 (test 2 - (name test_publicsuffix_cmd) 2 + (name test) 3 3 (libraries publicsuffix publicsuffix.cmd cmdliner alcotest))
+1
test/cmd/test.ml
··· 1 + let () = Alcotest.run "Publicsuffix_cmd" [ Test_publicsuffix_cmd.suite ]
+15 -20
test/cmd/test_publicsuffix_cmd.ml
··· 142 142 (* ---------- suite export ---------------------------------------------- *) 143 143 144 144 let suite = 145 - [ 146 - ( "publicsuffix_cmd", 147 - [ 148 - test_case "registrable_term" `Quick test_registrable_term; 149 - test_case "registrable_term suffix error" `Quick 150 - test_registrable_term_suffix; 151 - test_case "suffix_term" `Quick test_suffix_term; 152 - test_case "is_suffix_term true" `Quick test_is_suffix_term; 153 - test_case "is_suffix_term false" `Quick test_is_suffix_term_false; 154 - test_case "is_registrable_term" `Quick test_is_registrable_term; 155 - test_case "registrable_section_term" `Quick 156 - test_registrable_section_term; 157 - test_case "suffix_section_term" `Quick test_suffix_section_term; 158 - test_case "stats_term" `Quick test_stats_term; 159 - test_case "version_term" `Quick test_version_term; 160 - test_case "domain_arg missing" `Quick test_domain_arg_missing; 161 - ] ); 162 - ] 163 - 164 - let () = Alcotest.run "Publicsuffix_cmd" suite 145 + ( "publicsuffix_cmd", 146 + [ 147 + test_case "registrable_term" `Quick test_registrable_term; 148 + test_case "registrable_term suffix error" `Quick 149 + test_registrable_term_suffix; 150 + test_case "suffix_term" `Quick test_suffix_term; 151 + test_case "is_suffix_term true" `Quick test_is_suffix_term; 152 + test_case "is_suffix_term false" `Quick test_is_suffix_term_false; 153 + test_case "is_registrable_term" `Quick test_is_registrable_term; 154 + test_case "registrable_section_term" `Quick test_registrable_section_term; 155 + test_case "suffix_section_term" `Quick test_suffix_section_term; 156 + test_case "stats_term" `Quick test_stats_term; 157 + test_case "version_term" `Quick test_version_term; 158 + test_case "domain_arg missing" `Quick test_domain_arg_missing; 159 + ] )
+25 -40
test/test_publicsuffix.ml
··· 251 251 (* ---------- suite export ---------------------------------------------- *) 252 252 253 253 let suite = 254 - [ 255 - ( "public_suffix", 256 - [ 257 - test_case "basic lookups" `Quick test_suffix_basic; 258 - test_case "wildcard rules" `Quick test_suffix_wildcard; 259 - test_case "exception rules" `Quick test_suffix_exception; 260 - test_case "trailing dot" `Quick test_suffix_trailing_dot; 261 - test_case "error cases" `Quick test_suffix_errors; 262 - ] ); 263 - ( "registrable_domain", 264 - [ 265 - test_case "ICANN basic" `Quick test_reg_icann_basic; 266 - test_case "second-level suffix" `Quick test_reg_second_level; 267 - test_case "wildcard rules" `Quick test_reg_wildcard; 268 - test_case "exception rules" `Quick test_reg_exception; 269 - test_case "com is suffix" `Quick test_reg_com_is_suffix; 270 - test_case "trailing dot" `Quick test_reg_trailing_dot; 271 - test_case "error cases" `Quick test_reg_errors; 272 - test_case "IDN / punycode" `Quick test_reg_idn; 273 - test_case "mixed case" `Quick test_reg_mixed_case; 274 - ] ); 275 - ( "is_public_suffix", 276 - [ 277 - test_case "basic checks" `Quick test_is_suffix; 278 - test_case "error cases" `Quick test_is_suffix_errors; 279 - ] ); 280 - ( "is_registrable_domain", 281 - [ test_case "basic checks" `Quick test_is_registrable ] ); 282 - ( "section", 283 - [ 284 - test_case "suffix section" `Quick test_section_suffix; 285 - test_case "registrable section" `Quick test_section_registrable; 286 - ] ); 287 - ( "statistics", 288 - [ 289 - test_case "rule counts" `Quick test_rule_counts; 290 - test_case "version info" `Quick test_version_info; 291 - ] ); 292 - ] 254 + ( "publicsuffix", 255 + [ 256 + test_case "suffix basic lookups" `Quick test_suffix_basic; 257 + test_case "suffix wildcard rules" `Quick test_suffix_wildcard; 258 + test_case "suffix exception rules" `Quick test_suffix_exception; 259 + test_case "suffix trailing dot" `Quick test_suffix_trailing_dot; 260 + test_case "suffix error cases" `Quick test_suffix_errors; 261 + test_case "registrable ICANN basic" `Quick test_reg_icann_basic; 262 + test_case "registrable second-level suffix" `Quick test_reg_second_level; 263 + test_case "registrable wildcard rules" `Quick test_reg_wildcard; 264 + test_case "registrable exception rules" `Quick test_reg_exception; 265 + test_case "registrable com is suffix" `Quick test_reg_com_is_suffix; 266 + test_case "registrable trailing dot" `Quick test_reg_trailing_dot; 267 + test_case "registrable error cases" `Quick test_reg_errors; 268 + test_case "registrable IDN / punycode" `Quick test_reg_idn; 269 + test_case "registrable mixed case" `Quick test_reg_mixed_case; 270 + test_case "is_suffix basic checks" `Quick test_is_suffix; 271 + test_case "is_suffix error cases" `Quick test_is_suffix_errors; 272 + test_case "is_registrable basic checks" `Quick test_is_registrable; 273 + test_case "section suffix" `Quick test_section_suffix; 274 + test_case "section registrable" `Quick test_section_registrable; 275 + test_case "stats rule counts" `Quick test_rule_counts; 276 + test_case "stats version info" `Quick test_version_info; 277 + ] ) 293 278 294 - let () = run "Publicsuffix" suite 279 + let () = run "Publicsuffix" [ suite ]
+1
test/test_publicsuffix.mli
··· 1 + val suite : string * unit Alcotest.test_case list