-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
ClojureDocs formatting tweaks #3701
ClojureDocs formatting tweaks #3701
Conversation
b9e6911
to
ae5cd39
Compare
cider-clojuredocs.el
Outdated
(when-let ((doc (nrepl-dict-get dict "doc"))) | ||
(insert "\n") | ||
(let ((lines (mapcar (lambda (line) | ||
(replace-regexp-in-string "^\s+" "" line)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use string-trim-left
?
One thing to consider here, though, is how much to strip exactly, as I'm guessing that some docstrings might have intentional indentation on some lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, string-trim-left
will suffice in that case.
I'm not sure why we get these spaces in the docstring in the first place. Maybe it has something to do with ClojureDocs data.
But we can be sure that every line after the first one contains two additional spaces at the beginning, so maybe just removing exactly two spaces will be good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, they are here because this is a literal string from the source code. As there are generally two spaces at the beginning of lines in docstrings, I guess it will be okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I'm also not sure where those spaces are coming from, but I guess your solution is unlikely to break something in the formatting.
ae5cd39
to
2bebbba
Compare
cider-clojuredocs.el
Outdated
(insert (nrepl-dict-get dict "doc")) | ||
(insert "\n")) | ||
(when-let ((doc (nrepl-dict-get dict "doc"))) | ||
(insert "\n" (replace-regexp-in-string "\n " "\n" doc) "\n"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a note here regarding the need to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a note.
2bebbba
to
f2553a6
Compare
I plan to rework how ClojureDocs buffer is displayed (improve some formatting, make it more modular and customizable) and want to start with some small improvements.
This particular change:
*
and newline are no longer part of the button.This is how it looked before:
![cider-cheatsheet-formatting-tweaks-old](https://private-user-images.githubusercontent.com/93549926/336176571-af2c28d9-8415-4f0a-8de5-13f275f3f582.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ2NDA4ODEsIm5iZiI6MTcyNDY0MDU4MSwicGF0aCI6Ii85MzU0OTkyNi8zMzYxNzY1NzEtYWYyYzI4ZDktODQxNS00ZjBhLThkZTUtMTNmMjc1ZjNmNTgyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI2VDAyNDk0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA2NjNhYTFlZDgzZDFkMzJjYjJlNjY0MDFmZDUwOTY3YWEyYmQ4NTIxYzI1NmVhZmEwOTk2MjEyZTQ2MTJjOTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.KqkuNCP8EoRG6Aj_aDU-qZTdPdApv_Ibq9-4Jj4gP7c)
This is how it looks now:
![cider-cheatsheet-formatting-tweaks-new](https://private-user-images.githubusercontent.com/93549926/336176726-a64cf82c-972d-4800-ba7a-5033db6d2e1f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ2NDA4ODEsIm5iZiI6MTcyNDY0MDU4MSwicGF0aCI6Ii85MzU0OTkyNi8zMzYxNzY3MjYtYTY0Y2Y4MmMtOTcyZC00ODAwLWJhN2EtNTAzM2RiNmQyZTFmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI2VDAyNDk0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM5NTBiYjEwN2I2NzFmMjI3MjZjMzZlMDNmZmE5MmZiNmIzMmVkNGY1OTc3OWEyMjZmMTFhYmY2NmYyMGUzZDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.78v8z1SkhsqSoKTvwEe9r4TFn48ie7Ov3Xyy9_KbR7k)