Liking cljdoc? Tell your friends :D

com.blockether.parinferish

Parinfer for Clojure source — a pure-Java rewrite of parinferish 0.8.0 that is linear in the size of the file instead of quadratic.

repair is the whole library: source in, repaired source out.

(repair "(defn f [x]\n  (inc x)" {:mode :indent})
;; => "(defn f [x]\n  (inc x))"

parse returns the result object when you also want the errors or the exact edits, and flatten takes the text back out of it.

Modes: :indent trusts the indentation and moves the delimiters, :paren trusts the delimiters and moves the indentation, :smart uses indent mode for the collections that start before the cursor (:cursor-line, :cursor-column, both zero-based) and paren mode for the rest, and nil only reads — it repairs nothing and just reports error.

A source whose strings do not terminate, or that ends a line on a backslash, comes back verbatim in every mode: a file this library cannot read is a file it must not rewrite.

Parinfer for Clojure source — a pure-Java rewrite of parinferish 0.8.0 that is
linear in the size of the file instead of quadratic.

`repair` is the whole library: source in, repaired source out.

    (repair "(defn f [x]\n  (inc x)" {:mode :indent})
    ;; => "(defn f [x]\n  (inc x))"

`parse` returns the result object when you also want the errors or the exact
edits, and `flatten` takes the text back out of it.

Modes: `:indent` trusts the indentation and moves the delimiters, `:paren`
trusts the delimiters and moves the indentation, `:smart` uses indent mode for
the collections that start before the cursor (`:cursor-line`,
`:cursor-column`, both zero-based) and paren mode for the rest, and `nil` only
reads — it repairs nothing and just reports `error`.

A source whose strings do not terminate, or that ends a line on a backslash,
comes back verbatim in every mode: a file this library cannot read is a file
it must not rewrite.
raw docstring

changed?clj

(changed? result)

True when the repair changed anything.

True when the repair changed anything.
sourceraw docstring

editsclj

(edits result)

What the repair did, in output order: maps of :action (:insert/:remove), :offset, :line, :column (all zero-based, in the ORIGINAL source) and :text.

What the repair did, in output order: maps of `:action` (`:insert`/`:remove`),
`:offset`, `:line`, `:column` (all zero-based, in the ORIGINAL source) and
`:text`.
sourceraw docstring

errorclj

(error result)

The last problem the read found, or nil: "Unbalanced quote", "Backslash at end of line", "Unmatched delimiter", "EOF while reading".

The last problem the read found, or nil: `"Unbalanced quote"`,
`"Backslash at end of line"`, `"Unmatched delimiter"`, `"EOF while reading"`.
sourceraw docstring

flattenclj

(flatten result)

The repaired text of a parse result.

The repaired text of a `parse` result.
sourceraw docstring

parseclj

(parse source)
(parse source {:keys [mode cursor-line cursor-column]})

Reads source, applying the repair named by :mode. Returns a com.blockether.parinferish.Parinfer$Result: flatten it for the text, edits it for the changes, error it for the reason it could not read.

Reads `source`, applying the repair named by `:mode`. Returns a
`com.blockether.parinferish.Parinfer$Result`: `flatten` it for the text,
`edits` it for the changes, `error` it for the reason it could not read.
sourceraw docstring

repairclj

(repair source)
(repair source opts)

Repairs source and returns the text — (-> source (parse opts) flatten).

Repairs `source` and returns the text — `(-> source (parse opts) flatten)`.
sourceraw docstring

versionclj

This library's own release number.

This library's own release number.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close