-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fixes #4399 - Spacemacs documentation improvements and fixes. #5545
Conversation
We should discuss it. And if this is a proper way to go around - I'll write about the links in the Contributor guidelines and add .org validations to the Travis test suite. Also the most of the commits can be safely cherry picked. |
(with-temp-buffer | ||
(save-match-data | ||
(insert-file-contents filename t) | ||
(spacemacs//add-org-meta-readtheorg-css filename) |
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 can add a comment here to specify that any preprocess function should be added here.
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.
done.
A quick look at the PR tells me that it is pretty much what I wanted, nice work 👍 |
Merge conflicts :P |
@robbyoconnor Ya it's the last commit. It should be ditched anyway - I have no hope to keep it synced 😄 |
Not with that attitude you don't! |
fc12926
to
8cf294b
Compare
@syl20bnr I removed commits that change .org files and improved the formatting script.
This way the PR shouldn't get conflicts so often. |
cf11885
to
e9f9a53
Compare
Links to documentation sections can easily break since they are indexed by their order (i.e. #orgheadline8)
b000bb4
to
74c2359
Compare
Dropped Also squashed my refactorings. Ahh... The org layer also moved. Cool 😿 |
It removes the need to clutter Spacemacs documentation with Also it reduces the amount of bugs, because it's hard to get the path right.
Add new html preprocessors to the org-html-publish-to-html pipeline: - `spacemacs//toc-org-unhrefify-toc` - remove the `toc-org` modifications for the TOC - `spacemacs//org-heading-annotate-custom-id` - annotate org headings with the indexes that GitHub uses for linking. `org-html-publish-to-html` will use them instead of the default `#orgheadline{N}`. This way the GitHub links and the http://spacemacs.org/ links will be compatible." - `spacemacs//reroot-links` - find the links that start with https://github.com/syl20bnr/spacemacs/blob/ and end with .org{#an-optional-heading-link} (i.e the links between the local org files). Change their root to http://spacemacs.org/ so the links will point at files located on the site. *For the "file to file" links to work properly the expor
`space-doc-mode` - Buffer local minor mode for Spacemacs documentation files. The mode hides org meta tags. Enabled when viewing documentation via `SPC` `h` `SPC`
The https link-type opens the local copies of the Spacemacs documentation files with the spacemacs/view-org-file function. It supports GitHub style heading links For example, the link: https://github.com/syl20bnr/spacemacs/blob/develop/layers/org/README.org#links Will be handled similary to as if it was: file:~/.emacs.d/layers/org/README.org::*links Also the `space-doc' mode will be applied. Refactored GH style anchor search.
Add ./doc-fmt/ folder that contains the .org example and the script(run.bash) that should be run from the repo root. Its purpose: - remove #+HTML_HEAD_EXTRA: ... readtheorg.css" /> - replace :TOC_4_org:noexport: with :TOC_4_gh:noexport: - apply the gh style TOC
Remove #+HTML_HEAD_EXTRA: <link ... /readtheorg.css" /> :TOC_4_org:noexport: -> :TOC_4_gh:noexport:
updated |
One of my favorite PR, clean and fun to merge. Great job 💜 Thank you ! |
Thanks! 😊 |
I love you all |
The prime goal of this PR is to fix the Spacemacs documentation links in the Table Of Content at GitHub and introduce reliable method of linking headings from different files that will work in the Spacemacs and both at GitHub and spacemacs.org web sites.
I fixed all the merge conflict except the last commit (it's too global and will constantly brake)
In the discussion #4399 we came to the conclusion that the solution shouldn't modify local files in the Spacemacs installation - they should be the same locally and at the repository. Also we decided to use toc-org for table of content.
Since we can't change how GitHub handles links, I made Spacemacs and spacemacs.org use the GitHub style links - they should always work at GitHub. Also I added some of my PRs that overlaps with this one and smashed bugs, fixed typos that I encountered while implementing the fix. They all are in the separate commits so it shouldn't be a problem.
I'll explain each of the commits
query.stickytableheaders.js
(error 404) ebad4eb it causes 404 error at the Spacemacs website(open web-browser console to see it) The file isn't there anymore, but it's not crucial and the website should be fine without it.readtheorg.css
file. Also it adds unnecessary clutter The commit adds or fixes (if it's already there) the link during the export to html process. Also it implements a wrapper function that can chain all kind of the org file preprocessors (used later)spacemacs//toc-org-unhrefify-toc
- makes TOC_gh normal org TOC again.spacemacs//reroot-links
- If a link refers an org file or its heading and the file is in the Spacemacs GitHub repository, the function will rewrite the base of the link to http://spacemacs.org/ | example | exported org file.spacemacs//org-heading-annotate-custom-id
- adds GitHub style ids to the exported headings so they can be referred in the same way as at the GitHub web site. For the more info read the commit message.org-mode
https
link type handler that brings GitHub links to the Spacemacs(including links to headings) In a similar fashion tospacemacs//reroot-links
if a link refers an org file or its heading and the file is in the Spacemacs GitHub repository, the handler will open the local copy of the file withspacemacs/view-org-file
(this is howSPC
h
SPC
opens them) or if it's not in there - the link will be opened in the browser. The functionspacemacs/view-org-file
applies visual enhancements like the indent mode andspace-doc-mode
so the opened files also will be prettified. And since those are the GItHub style links they will work at the GitHub, Spacemcs and spacemacs.org. For example:[[https://github.com/syl20bnr/spacemacs/blob/master/doc/FAQ.org#os-x][Link to FAQ "OS X" heading]]
leads to (the image is clickable)[[https://www.google.com][Link to www.google.com]]
leads to https://www.google.comThis is more reliable and flexible way to link files and headings than the default
org-mode
one - if we want it to work at the GitHub, in the Spacemacs and at its web site. + it adds pretifiers.toc-org
will build GitHub TOC when the org files are saved.PR TEST COMMIT1706d3ftoc-org-gh.el
script for the applyingtoc-org
to all the org files in the batch mode and example files for the PR. You can call the script from the repo root withfind . -name "*.org" -type f -exec emacs -batch -l ./doc/pr-test/toc-org-gh.el '{}' -f toc-apply \;
toc-org-gh.el
- not for merge. Can be easily reproduced by running the script. Probably should be split into a couple of commits, because it makes git crush - too many changes?This is my magnum opus. Those lines shall be carved on my tombstone 😄
@syl20bnr @TheBB @StreakyCobra @a13ph @robbyoconnor @d12frosted and everyone else! Be the witnesses of my glory or the miserable failure!