Coder Social home page Coder Social logo

utensil / format_lean Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leanprover-community/format_lean

1.0 2.0 0.0 136 KB

A Lean file formatter

Home Page: https://leanprover-community.github.io/format_lean/

License: Apache License 2.0

CSS 30.93% JavaScript 3.46% Python 63.28% Shell 0.26% HTML 2.07%

format_lean's Introduction

Lean formatter

This prototype is a python library which renders convert Lean files to other files, for instance another Lean file of a html file.

Installation

You need Python 3.7 or later, and Lean. Make sure the python package manager pip is installed. Clone this repository, go to its root directory and run pip install . (using sudo -H if needed). It's also recommended to install ipython for interactive use. Alternatively, if you don't want to mess up with your global python environment, you can use a dedicated virtual environment. This is explained in the more complete installation guide.

Usage

If you only want to play with my example formatter you can simply run format_lean (which should be in your path if pip install . did its job). The basic usage is:

format_lean --inpath limits.lean --outdir build --lib-path /usr/lib/lean-mathlib/src

if you are in a folder containing limits.lean, have mathlib in /usr/lib/lean-mathlib, and want to render into directory build. See format_lean -- --help for more option.

Of course you need to point to your local copy of mathlib (unless you don't need mathlib?!). You can use --toolchain if your default elan toolchain isn't appropriate (you do use elan, right?). Optional arguments also include outpath if replacing .lean by .html is not good enough, and templates if you want to point to an alternate template directory.

The script source in the bin folder of this repository is a good entry point to understand how to customize more.

If you get addicted to it, and want to render a full Lean project, you can go to the root of the project (the folder containing leanpkg.toml) and run format_project. Optional arguments --outdir my_dir and --template as above. There is no need to point out a toolchain or dependencies since those are indicated in your leanpkg.toml. If you want to exclude files src/hide_me.lean and src/secret.lean from the rendering process, you can create a file format.toml next to your leanpkg.toml containing exclude = ['hide_me.lean', 'secret.lean']. On the other extreme, if you want to render only public.lean, you can use only = ['public.lean']. In this file you can also put template = "path" where path is the relative path to a folder containing jinja templates to be used instead of the default ones.

When using format_project, you can put a file format_lang.toml containing some translations, say:

Example = "Exemple"
Lemma = "Lemme"
Theorem = "Théorème"
Proof = "Démonstration"

format_lean's People

Contributors

kbuzzard avatar patrickmassot avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.