Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise documentation #249

Merged
merged 26 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
12b12af
Fix Kwarg.__repr__()
gilch Dec 27, 2023
96f94d3
macros.lissp is smaller than it looks
gilch Dec 27, 2023
11cd27b
Update Whirlwind Tour for tag##/||
gilch Dec 27, 2023
08f5e35
Fix some typos in primer.rst
gilch Dec 27, 2023
c5f0013
Primer clarifications
gilch Dec 27, 2023
789c0b4
Fix TOKENS regex
gilch Dec 29, 2023
359d0b5
Revise inject section exposition
gilch Dec 29, 2023
a087fbf
Note <<# equivalent in its docstring
gilch Dec 29, 2023
081aaa1
Clean up leftover #"" in README.md
gilch Dec 29, 2023
11d06ae
Swap out radical extensibility quote
gilch Dec 29, 2023
670b2b6
Mention that macros come bundled
gilch Dec 29, 2023
7c22d85
Mention Hissp's size without docs.
gilch Dec 29, 2023
24eaaff
Clean up leftover #"" in style_guide.rst
gilch Dec 29, 2023
d6e808a
Add Avoid Trailing Whitespace section
gilch Dec 29, 2023
b53bd77
Style Guide clarifications and typos
gilch Dec 29, 2023
e814f49
Write docs/README.md
gilch Dec 29, 2023
e6b2b67
Add small docstring for lissp_lexer.py
gilch Dec 29, 2023
ef094ac
Update copyright dates in docs/
gilch Dec 29, 2023
74882f3
Revise macro_tutorial.rst
gilch Dec 30, 2023
28cdf3f
Fix colors on GitHub via MathJax
gilch Dec 30, 2023
406b612
Clean up leftover .#"" in README.md
gilch Dec 31, 2023
36613a2
Add tests/README.md
gilch Dec 31, 2023
01d3053
Use string terminology more consistently
gilch Jan 1, 2024
0bfa47a
Use new fragment syntax in macros.lissp
gilch Jan 1, 2024
1e56fea
Fix typos
gilch Jan 1, 2024
a22cb56
Minor corrections from review
gilch Jan 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ branch(
no

```
A number of useful macros come bundled with Hissp.

## The Lissp Reader
The Hissp data-structure language can be written directly in Python using the "readerless mode" demonstrated above,
Expand Down Expand Up @@ -248,8 +249,8 @@ Requires [Bottle.](https://bottlepy.org/docs/dev/)
(enjoin "<"tag">"(enjoin : :* contents)"</"(get#0 (.split tag))">")))

(defmacro script (: :* forms)
`',(tag "script type='text/python'" #"\n"
(.join #"\n" (map hissp.compiler..readerless forms))))
`',(tag "script type='text/python'" "\n"
(.join "\n" (map hissp.compiler..readerless forms))))

((bottle..route "/") ; https://bottlepy.org
O#(enjoin
Expand All @@ -261,8 +262,8 @@ Requires [Bottle.](https://bottlepy.org/docs/dev/)
(define getf@v X#(float (X#X.value (getE X))))
(define set@v XY#(setattr (getE Y) 'value X))
(attach browser..window
: Celsius O#(-> (getf@v 'Celsius) (X#.#"X*1.8+32") (set@v 'Fahrenheit))
Fahrenheit O#(-> (getf@v 'Fahrenheit) (X#.#"(X-32)/1.8") (set@v 'Celsius))))
: Celsius O#(-> (getf@v 'Celsius) (X#|X*1.8+32|) (set@v 'Fahrenheit))
Fahrenheit O#(-> (getf@v 'Fahrenheit) (X#|(X-32)/1.8|) (set@v 'Celsius))))
(let (row (enjoin (tag "input id='{0}' onkeyup='{0}()'")
(tag "label for='{0}'" "°{1}")))
(enjoin (.format row "Fahrenheit" "F")"<br>"(.format row "Celsius" "C"))))))
Expand Down Expand Up @@ -317,16 +318,16 @@ Given Hebigo's macros, the class above could be written in the equivalent way in
(def_ (.test_two self x y)
:@ (given (st.from_type type)
(st.from_type type))
(self.assertIs .#"x or y" (or_ x y)))
(self.assertIs |x or y| (or_ x y)))
(def_ (.test_shortcut self)
(or_ 1 .#"0/0")
(or_ 0 1 .#"0/0")
(or_ 1 .#"0/0" .#"0/0"))
(or_ 1 |0/0|)
(or_ 0 1 |0/0|)
(or_ 1 |0/0| |0/0|))
(def_ (.test_three self x y z)
:@ (given (st.from_type type)
(st.from_type type)
(st.from_type type))
(self.assertIs .#"x or y or z" (or_ x y z))))
(self.assertIs |x or y or z| (or_ x y z))))
```

Hebigo looks very different from Lissp, but they are both Hissp!
Expand Down Expand Up @@ -478,11 +479,17 @@ which includes Clojure-like persistent data structures.
# Features and Design

## Radical Extensibility
> *Any sufficiently complicated C or Fortran program contains an ad hoc,
informally-specified, bug-ridden, slow implementation of half of Common Lisp.*
— Greenspun's Tenth Rule

Python is already a really nice language, a lot closer to Lisp than C or Fortran.
> A Lisp programmer who notices a common pattern in their code can write a macro to give themselves a source-level
> abstraction of that pattern. A Java programmer who notices the same pattern has to convince Sun that this particular
> abstraction is worth adding to the language. Then Sun has to publish a JSR and convene an industry-wide "expert group"
> to hash everything out. That process--according to Sun--takes an average of 18 months. After that, the compiler writers
> all have to go upgrade their compilers to support the new feature. And even once the Java programmer's favorite compiler
> supports the new version of Java, they probably still can't use the new feature until they're allowed to break source
> compatibility with older versions of Java. So an annoyance that Common Lisp programmers can resolve for themselves
> within five minutes plagues Java programmers for years.
> — Peter Seibel (2005) *Practical Common Lisp*

Python is already a really nice language, a lot closer to Lisp than to C or Fortran.
It has dynamic types and automatic garbage collection, for example.
So why do we need Hissp?

Expand Down Expand Up @@ -572,6 +579,8 @@ Hissp's powerful macro system means that additions to the compiler are
rarely needed.
Feature creep belongs in external libraries,
not in the compiler proper.
If you strip out the documentation and blank lines,
The `hissp` package only has around 1200 lines of actual code left over.

Hissp compiles to an unpythonic *functional subset* of Python.
This subset has a direct and easy-to-understand correspondence to the Hissp code,
Expand Down
31 changes: 29 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
- https://hissp.readthedocs.io/
- https://gitter.im/hissp-lang/community
<!--
Copyright 2023 Matthew Egan Odendahl
SPDX-License-Identifier: CC-BY-SA-4.0
-->
# Hissp Documentation
This directory contains the reStructuredText source of Hissp's documentation,
along with associated configuration and helper files,
including the Lissp syntax highlighter.
A significant additional portion of Hissp's rendered documentation is derived from
docstrings in Hissp's source code (the API docs).

## Quick Links
${\boldsymbol {\color{royalblue}{(}\color{green}{\textsf -}\color{gold}{)}\color{gainsboro}{\kern-1.5pt{\textsf :}}}}$
[Rendered Documentation ](https://hissp.readthedocs.io/) 🢦 START HERE.
[**m**] [Community Chat](https://gitter.im/hissp-lang/community)
⭐ [On GitHub (Source Code)](https://github.com/gilch/hissp)
🗪 [Discussions Page](https://github.com/gilch/hissp/discussions)
🕸 [Hissp Wiki](https://github.com/gilch/hissp/wiki)

## Building Docs
Hissp proper has no dependencies, but its documentation is built with Sphinx.
Install documentation dependencies from this directory with
```
pip install -r requirements.txt
```
Docs are typically built with
```
make html
```
2 changes: 1 addition & 1 deletion docs/_templates/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2022 Matthew Egan Odendahl
Copyright 2022, 2023 Matthew Egan Odendahl
SPDX-License-Identifier: Apache-2.0
-->
{% extends '!base.html' %}
Expand Down
2 changes: 1 addition & 1 deletion docs/command_line_reference.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. Copyright 2020, 2021, 2022 Matthew Egan Odendahl
.. Copyright 2020, 2021, 2022, 2023 Matthew Egan Odendahl
SPDX-License-Identifier: CC-BY-SA-4.0

Command Line Reference
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Adapted from Sphinx configuration template. Changes
# copyright 2019, 2020, 2021, 2022 Matthew Egan Odendahl
# copyright 2019, 2020, 2021, 2022, 2023 Matthew Egan Odendahl
# SPDX-License-Identifier: Apache-2.0

# Configuration file for the Sphinx documentation builder.
Expand Down
2 changes: 1 addition & 1 deletion docs/hissp.macro.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. This source file is part of Hissp's documentation,
copyright 2019, 2021 Matthew Egan Odendahl
copyright 2019, 2021, 2022, 2023 Matthew Egan Odendahl
SPDX-License-Identifier: CC-BY-SA-4.0

hissp.macros module
Expand Down
4 changes: 4 additions & 0 deletions docs/hissp.macros.lissp.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. This source file is part of Hissp's documentation,
copyright 2023 Matthew Egan Odendahl
SPDX-License-Identifier: CC-BY-SA-4.0

:orphan:

Source code for hissp.macros
Expand Down
5 changes: 4 additions & 1 deletion docs/lissp_lexer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright 2020, 2021, 2022 Matthew Egan Odendahl
# Copyright 2020, 2021, 2022, 2023 Matthew Egan Odendahl
# SPDX-License-Identifier: Apache-2.0
"""
Pygments Lexer for Lissp syntax highlighting.
"""
import re

import pygments.token as pt
Expand Down
Loading
Loading