/- Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. Released under Apache 2.0 license. Authors: Joseph Tooby-Smith -/ import HepLean.Meta.Informal.Post import Mathlib.Lean.CoreM /-! # HepLean Stats This file concerns with statistics of HepLean. -/ open Lean System Meta HepLean def getStats : MetaM String := do let noDefsVal ← noDefs let noLemmasVal ← noLemmas let noImportsVal ← noImports let noDefsNoDocVal ← noDefsNoDocString let noLemmasNoDocVal ← noLemmasNoDocString let noLinesVal ← noLines let noInformalLemmasVal ← noInformalLemmas let s := s!" Number of Files 📄: {noImportsVal} Number of lines 💻: {noLinesVal} Number of Definitions (incl. instances): {noDefsVal - noInformalLemmasVal} - Of which {noDefsNoDocVal} do not have doc-strings Number of Lemmas: {noLemmasVal + noInformalLemmasVal} - Of which {noLemmasNoDocVal} do not have doc-strings" pure s unsafe def Stats.toHtml : MetaM String := do let noDefsVal ← noDefs let noLemmasVal ← noLemmas let noImportsVal ← noImports let noDefsNoDocVal ← noDefsNoDocString let noLemmasNoDocVal ← noLemmasNoDocString let noLinesVal ← noLines let noInformalDefsVal ← noInformalDefs let noInformalLemmasVal ← noInformalLemmas let noTODOsVal ← noTODOs let noFilesWithTODOsVal ← noFilesWithTODOs let header := "--- layout: default --- Stats for HepLean " let body := s!"

Stats for HepLean

Number of Files 📄: {noImportsVal}

Number of lines 💻: {noLinesVal}

Number of Definitions (incl. instances): {noDefsVal - noInformalLemmasVal}

- Of which {noDefsVal - noDefsNoDocVal- noInformalLemmasVal} have doc-strings:

- Of which {noDefsVal - noInformalLemmasVal - noInformalDefsVal} are not informal definitions:

Number of Lemmas: {noLemmasVal + noInformalLemmasVal}

- Of which {noLemmasVal - noLemmasNoDocVal + noInformalLemmasVal} have doc-strings:

- Of which {noLemmasVal} are not informal lemmas:

Number of TODOs: {noTODOsVal}

- There are {noImportsVal - noFilesWithTODOsVal} (of {noImportsVal}) files which are TODO free:

" let footer := " " pure (header ++ "\n" ++ body ++ "\n" ++ footer) unsafe def main (args : List String) : IO UInt32 := do let _ ← noImports let statString ← CoreM.withImportModules #[`HepLean] (getStats).run' println! statString if "mkHTML" ∈ args then let html ← CoreM.withImportModules #[`HepLean] (Stats.toHtml).run' let htmlFile : System.FilePath := {toString := "./docs/Stats.html"} IO.FS.writeFile htmlFile html IO.println (s!"HTML file made.") pure 0