Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. import tactic.interactive
  2.  
  3. open tactic declaration environment
  4.  
  5. /-- test that name was not auto-generated -/
  6. @[reducible] def name.is_not_auto (n : name) : Prop :=
  7. n.components.ilast ∉ [`no_confusion, `rec_on, `cases_on, `no_confusion_type, `sizeof,
  8. `rec, `mk, `sizeof_spec, `inj_arrow, `has_sizeof_inst, `inj_eq, `inj]
  9.  
  10. /-- Print the declaration name if it's a definition without a docstring -/
  11. meta def print_item (env : environment) (decl : declaration) : tactic unit :=
  12. match decl with
  13. | (defn n _ _ _ _ _) := do { ds ← doc_string decl.to_name, skip } <|>
  14. when n.is_not_auto (trace n)
  15. | (cnst n _ _ _) := do { ds ← doc_string decl.to_name, skip } <|>
  16. when n.is_not_auto (trace n)
  17. | _ := skip
  18. end
  19.  
  20. /-- Print all definitions in the current file without a docstring -/
  21. meta def print_docstring_orphans : tactic unit :=
  22. do curr_env ← get_env,
  23. let decls := curr_env.fold [] list.cons,
  24. let local_decls := decls.filter
  25. (λ x, environment.in_current_file' curr_env (to_name x) && not (to_name x).is_internal),
  26. local_decls.mmap' (print_item curr_env)
  27.  
  28. setup_tactic_parser
  29.  
  30. reserve prefix `#doc_blame`:max
  31.  
  32. @[user_command]
  33. meta def doc_cmd (_ : decl_meta_info) (_ : parse $ tk "#doc_blame") : lean.parser unit :=
  34. print_docstring_orphans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement