/- Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. Released under Apache 2.0 license. Authors: Joseph Tooby-Smith -/ import PhysLean.Meta.Informal.Post import Mathlib.Lean.CoreM /-! # PhysLean Stats This file concerns with statistics of PhysLean. -/ open Lean System Meta PhysLean 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 ---
- Of which {noDefsVal - noDefsNoDocVal- noInformalLemmasVal} have doc-strings:
- Of which {noDefsVal - noInformalLemmasVal - noInformalDefsVal} are not informal definitions:
- Of which {noLemmasVal - noLemmasNoDocVal + noInformalLemmasVal} have doc-strings:
- Of which {noLemmasVal} are not informal lemmas:
- 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 #[`PhysLean] (getStats).run' println! statString if "mkHTML" ∈ args then let html ← CoreM.withImportModules #[`PhysLean] (Stats.toHtml).run' let htmlFile : System.FilePath := {toString := "./docs/Stats.html"} IO.FS.writeFile htmlFile html IO.println (s!"HTML file made.") pure 0