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
Ns index summary #25
Ns index summary #25
Conversation
Ping. |
My apologies for letting this drop off my radar. You'll first need to remove the version bump and the dependency updates. Pull requests should be focused on a single change, and they should never increment the project version (particularly since so minor a change doesn't justify a bump from 0.6.4 to 0.7.0). The summary function itself is lopsided, in that it has a trim with one argument, but not when there are two are more. Additionally, support for multiple regular expressions is unnecessary, as regular expressions can be concatenated using "|". I'd also be inclined drop support for "\f", as I've never seen that in a source file. |
I will pull those commits out. Do you prefer reverting them individually, or rebasing them and force pushing to the source branch? I would like to see the dependencies updated, since Clojure 1.2.x is quite old by now and it's inconvenient to download that dependency purely for this tool. I would be glad to break that out into a separate PR, if you're amenable to updating it in the first place. I pushed an update to The page break character is Both regexps are necessary to accomplish this, because regexp syntax has no way to short circuit on a match, so |
Rebase and force-push please.
Leiningen resolves dependencies based on how "close" they are. If you specify Clojure 1.5.1 in your project.clj file, this will override any Clojure version loaded in as a second-level dependency. So the version of Clojure Codox depends on will, in most cases, have no effect on the project it's generating documentation for. The Clojure dependency Codox relies on represents a lowest common denominator. If the version of Clojure in Codox is updated to 1.5, then functions or language features might creep into Codox that would prevent it from working on projects that rely on older dependencies. It therefore makes sense to keep the Clojure dependency in Codox as low as possible.
Do you have any examples where this technique is in use? |
I force-pushed. I don't know of major projects that use page breaks, but I found a couple examples: I find them helpful, and use them extensively in my code. That said, it is somewhat edge-casey and likely has low discoverability, so I would be okay removing it if you don't see value in the feature. |
Including |
Your implementation of (defn summary [s]
(str/trim (first (str/split s #"\f|\n\n")))) Also, it would make sense to put the (defn summary [s]
(first (str/split (str/trim s) #"\f|\n\n"))) Or: (defn summary [s]
(-> s str/trim (str/split #"\f|\n\n") first)) |
The use of loop/recur may seem odd, but it is deliberate. Using a simple regex is not equivalent:
This defeats the purpose of supporting ^L in the first place; you may as well unconditionally split on If you're against using loop/recur, I can turn it into a nested conditional, but I chose loop/recur to eliminate the redundancy that approach would entail. |
Hm, okay, so what about: (defn summary [s]
(re-find #"(?s).*?(?=\f)|.*?(?=\n\n)|.*" s)) |
Yeah, that works and seems cleaner — though I think the regex is harder to read. I pushed an update. |
I guess it depends on how much you read regular expressions :) The |
If the
|
But since this is being inserted into HTML, whether you trim the output or not doesn't affect what the user sees. On the other hand, if you have a docstring with leading newlines (for whatever reason) trimming it before passing it to the regex will produce the correct summary instead of string of whitespace. |
All the issues in this PR seems to be resolved. Is there any reason why it shouldn't be merged? |
The last issue I commented on has not been resolved. |
My mistake, I missed it. |
I've created a new pull request where trimming is done before passing the docstring to the regex. |
Fixed by #41 |
This changes the generated index to use a summary of the ns docstring rather than the whole string. This change lets you put a one- or two-line summary of the ns in the docstring, followed by extensive documentation and examples, without cluttering the ns index page. The complete docstring is still displayed on the ns-specific doc page.
Additionally, this updates some dependencies and the codox version.