Truncate too big code samples while focusing on a certain line
Truncate too big code samples while focusing on a certain line
(truncate code focus-line max-lines)
Truncate code samples longer than max-lines. focus-line indicates which line should be at the center of the returned excerpt. truncate will attempt to return the relevant lines that encompasses the whole form of which focus-line is a part. In most cases, this means to return the function a line is found in for Clojure code, and the class a line is in for Java code.
TODO: Because most Java files contain one class, it is very likely that this function will return an excerpt that is almost as big as the original code when dealing with Java code (because Java files typically only have one top-level form). This could be improved by detecting Java methods, and extracting only those instead.
Truncate code samples longer than max-lines. focus-line indicates which line should be at the center of the returned excerpt. truncate will attempt to return the relevant lines that encompasses the whole form of which focus-line is a part. In most cases, this means to return the function a line is found in for Clojure code, and the class a line is in for Java code. TODO: Because most Java files contain one class, it is very likely that this function will return an excerpt that is almost as big as the original code when dealing with Java code (because Java files typically only have one top-level form). This could be improved by detecting Java methods, and extracting only those instead.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close