Skip to content
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

Making contributions smoother #20

Closed
kousu opened this issue Oct 25, 2021 · 16 comments · Fixed by #21
Closed

Making contributions smoother #20

kousu opened this issue Oct 25, 2021 · 16 comments · Fixed by #21
Labels
bug Something isn't working supporting infrastructure Scripts, CI, build tools, hosting theme Layout, CSS, HTML, colour scheme, etc

Comments

@kousu
Copy link
Member

kousu commented Oct 25, 2021

Gitbook released a new version with a lot of changes (without warning) that needed some quick action on our part to reset user permissions to get things working again. This has motivated some internal discussions about how to work with it.

In particular, the "Edit on Github" button is currently broken; it seems that it's supposed to be supported

screenshot_2021-10-21_at_12-00-04_home_-_neuropoly_internal

but it's disabled for us for some reason; maybe because we were migrated instead of created fresh and are now in some sort of legacy mode.

More broadly, since the summer we've been in an uncomfortable limbo, maintaining our docs with two UIs: this repo, and with app.gitbook.io. The new Gitbook version is especially pushing its WYSIWYG editor, making it more like Notion.so or Google Docs and I think this is the best moment to summarize the tension and settle on one workflow.

@kousu
Copy link
Member Author

kousu commented Oct 25, 2021

Cons of Gitbook

  1. It's lock-in SaaS software.

    Gitbook 1.0, still online at https://github.com/GitbookIO/gitbook, was a nice static site generator, like sphinx, with a lot of aesthetically pleasing defaults. It's best feature was that its input was markdown (so, nearly plain text) and that it could be self-hosted.

    I originally supported using Gitbook because it promised to be "just markdown". But that's not what v2 is

    Screenshot 2021-10-25 at 17-28-25 Important differences

    "a GitBook specific versioning system" means "a proprietary format that only exists on our servers". It's probably some hodge-podge of JSON. This explains why Flakey gitbook sync #9 is such a problem, and why export/import to Github is only going to get worse, not better, with time.

    This is not a future-proof format. It is not something we can archive. So long as their github integration is working we can export and recover if we need to, maybe, but we've already used a bunch of unportable gitbook-specific features like {% tabs %} that will be a pain to redo the day that Gitbook pivots.

  2. It subjects our users, and us, to surveillance capitalism

    The first clue to this is the GDPR cookie warning they have:

    Screenshot 2021-10-25 at 16-58-15 Page not found - GitBook Documentation

    In fact I can't use it in my normal browser because clicking a link will often trigger

    Screenshot 2021-10-25 at 16-58-09 Page not found - GitBook Documentation

    I debugged this a little bit and one trigger is blocking Firebase; it seems that Gitbook needs to contact Firebase once, but it doesn't actually store its content there because if I allow it once then keep it blocked it renders content fine. So is it setting some sort of tracking cookie, and without the tracking cookie I can't read the content at all? What could justify that?

    Here's all the sites it needs to contact, just to render a wiki:

    2021-10-25-165935_1911x840_scrot
    2021-10-25-165945_1907x812_scrot

    It clearly doesn't actually need all that, because fully disabling javascript, even 1st-party javascript, renders fine:

    2021-10-25-170935_1717x895_scrot

    But the fact that they feel entitled to make these requests on my behalf bothers me.

    I make a habit to reject these consent banners whenever I can, and I don't think anyone else should have to feel pressured into accepting them just to get their work done, or even just to explore what we're about non-committally.

  3. It's really javascript heavy, even for read-only use.

    See the previous point: it mysteriously overlays an modal error message sometimes without explanation. If javascript is off entirely it never does, but if it's partially on then it refuses to let me use it, sometimes, when it feels like being obstructive.

    Similarly, I can't even log in to it if I am blocking third party trackers. Other sites manage to do OAuth without javascript handling the auth tokens; I don't know why Gitbook needs it? If I try it with tracking protection on, I just get

    Screenshot 2021-10-25 at 17-19-47 Join GitBook - GitBook

    The in-page sub-table-of-contents used to not render with javascript disabled

    Screenshot 2021-10-25 at 17-53-05 Facilities - NeuroPoly Lab

    but in this one case they seem to have improved, and gone towards using universal HTML instead of javascript.

    So: v1 was a static site generator. v2 has regressed to leaning heavily into javascript.

    Not all of us can keep up with the latest expensive macbooks that startup devs all code on! Ease of UI is important for accessibility, but another important dimension of accessibility is the resource drain it demands.

    For me, the main reason keeping me away from editing Gitbook is how many hoops it makes me jump through: disable all my blockers, close any other tabs like Google Docs or Messenger that are also DHTML heavy so I don't epuise my RAM.

  4. It's an unstable product.

    The surprise permissions glitch and the broken Edit on Github banner aren't the first bugs we've had with them. Flakey gitbook sync #9 continues to be a problem, and with them pushing their live editor I predict the git side will continue to get less and less maintenance. This is a symptom of v2 being produced by a startup searching for product-market fit, and losing their v1 roots as a solid tool.

    Another bug is that everytime we reuse an image, like all the social media icons on https://www.neuro.polymtl.ca/team, it duplicates each. See all the dupes here: https://github.com/neuropoly/neuropoly-docs/tree/601e159/.gitbook/assets

    Screenshot 2021-10-26 at 18-10-05 neuropoly-docs gitbook assets at 601e159ce70eefd612f14167d77c495040f75e9a · neuropoly neu

    Another bug is that it gets confused when pages are moved around: "Deleted" and moved pages still exist intranet.neuro.polymtl.ca#7; even right now https://github.com/neuropoly/neuropoly-internal-docs/tree/82dea057ecda6a3430821edbaaf9d48411e64f32/mri-coils is an old version of https://github.com/neuropoly/neuropoly-internal-docs/tree/82dea057ecda6a3430821edbaaf9d48411e64f32/mri-scanning but it doesn't appear in the WYSIWYG editor anywhere so there's no way to know it's there, falling out of date.

    Another bug is that, bizarrely, despite supporting an internal {% embed %} tag, it does not support Google calendar embedding despite this being an ancient and widely spread feature of the public internet: Embed google calendar intranet.neuro.polymtl.ca#10. 💢 It seems {% embed %} is outsourced to a company that's literally called https://iframe.ly and I guess they just..don't do Google? Or something?

    For documentation, we should want something boring that we know we can rely on, archive, and restore as needed. That doesn't mean it has to be unattractive, there are many static site generators with very pretty themes.

    For obvious evidence of its instability, their v1 repo, which is still pinned on their Github

    Screenshot 2021-10-25 at 17-24-44 GitBook

    has a dead link to their migration guide

    Screenshot 2021-10-25 at 17-24-59 GitbookIO gitbook 📝 Modern documentation format and toolchain using Git and Markdown

    to https://docs.gitbook.com/v2-changes/important-differences that just 404s now.

  5. It requires extra accounts.

    Another reason I originally supported switching off DokuWiki was because account creation on Dokuwiki was slow. @alexfoias runs all over our platforms doing admin and sometimes things just pile up, so it would take some time to grant wiki accounts to newcomers. Switching to Gitbook allowed us to have people self-inscribe with the Gitbook Team Invite Link, and allowed people to use Sign In With Github to avoid remembering another password.

    But the accounts on app.gitbook.io are still their own thing. It means in addition to managing https://github.com/orgs/neuropoly/people, we need to spend admin time onboarding, offboarding, and auditing https://app.gitbook.com/o/-MYD1C9e-AHCd61VhjhF/settings/members, and it means time manually synchronizing permissions between the two apps (e.g. Ainsleigh was still the owner on Gitbook until a couple days ago, despite not working for the lab for a month+ now). It means people need to write down in their password manager whether they used a password or Sign In With Github with Gitbook -- but in practice I bet most of us have just forgotten and need to be reminded "try sign in with Github" when it comes up; and if that fails, they need to bug one of the admins to help them figure out what step is missing.

    So switching to Gitbook hasn't reduced the account overhead, in my opinion.

  6. It's another language to know.

    I also supported moving away from DokuWiki because, I thought, on top of it being slow to get an account, it was slow to learn its wiki markup. Markdown and RST are the dominant markup languages now, and everyone in the lab has to know them to work on our projects, but having to know a third just for the wiki was a big ask.

    By being able to write our lab manual in markdown we save brain space.

    But they're not really a markdown renderer anymore (see above). Instead they're really their own format, that can only be edited with their WYSIWYG editor. That makes it another third language; just instead of a plain text language, it's a visual and kinetic one, with its own quirks.

@kousu
Copy link
Member Author

kousu commented Oct 25, 2021

Pros of Gitbook

  1. It's table of contents in the default theme is very readable

    This is great:

    Screenshot 2021-10-25 at 17-49-54 Research - NeuroPoly Lab

    the inline ToC is great

    Screenshot 2021-10-25 at 17-53-05 Facilities - NeuroPoly Lab

  2. People can self-onboard.

    I still think the admin side is at least, maybe more, complicated with Gitbook than Dokuwiki, but at least people don't need to wait on us to grant them accounts when they join.

@jcohenadad
Copy link
Member

Thank you sooooo much for the thorough evaluation, @kousu . This is amazing. All the arguments you have raised make sense. Do you have suggestions of alternative products (keeping in mind the specs that we are after, ie, "easy" editing)?

I would like to hear some feedback from the rest of the team also.

@kousu
Copy link
Member Author

kousu commented Oct 26, 2021

Alternative(s) to Gitbook

I think we should start with the constraint that we keep this repo alive and use the Github editor for editing the wiki. Then we only have the one set of accounts and permissions to manage.

Screenshot 2021-10-26 at 14-28-08 Editing neuropoly-docs collaborations md at master · neuropoly neuropoly-docs

their editor isn't live or WYSIWYG but it has Preview one click away:

Screenshot 2021-10-26 at 14-28-20 Editing neuropoly-docs collaborations md at master · neuropoly neuropoly-docs

We should make sure to leave this repo unprotected so everyone in the lab can edit without having to go through PRs. (but people can still use PRs if they want feedback).

Screenshot 2021-10-26 at 14-31-17 Options · neuropoly neuropoly-docs

Then, as for reading and using it, I have two ideas:

Just use Github

I think in the short term we could go replace our A record with a HTTP 301 redirect and/or an HTML <meta> redirect that bounces people from https://neuro.polymtl.ca -> https://github.com/neuropoly/neuropoly-docs/. namecheap can do this, or we'd have to have polyit point neuro.polymtl.ca back at some internal server that we could control. In the even shorter term we could just erase all the content on Gitbook and put a big "Please Click here".
Screenshot 2021-10-26 at 14-28-08 Editing neuropoly-docs collaborations md at master · neuropoly neuropoly-docs

Aesthetics

The default Github markdown renderer is fine IMO. It renders text and images and it's elegant enough. We can't control it or put our logo in the corner, but in a pinch it's serviceable.

Primary Table of Contents

Instead of a sidebar, it just has a directory hierarchy:

2021-10-26-134456_950x505_scrot

This isn't great but it's also not the worst, especially since the folder names are sensible.

Secondary Table of Contents

Github has a per-page ToC generator, as of sometime last year:

facilities ToC

publications ToC

It doesn't render on pages that only have one heading:

software-developer has no ToC

and it's a little bit unobvious, but it's there.

Edit on Github

Github, of course, has an edit button built in

Edit on Github

Hosting

Hosting is built in because Github renders markdown files in its web UI by default.

Instead, use Sphinx

We use sphinx in all our other repos, e.g. https://github.com/spinalcordtoolbox/spinalcordtoolbox/tree/master/documentation/source renders to https://spinalcordtoolbox.com/, the same for shimming-toolbox.org/, https://axondeepseg.readthedocs.io/en/latest/, etc. We can use it here too.

sphinx supports markdown (via a plugin) so we don't need much rewriting. Mostly we just need to add the sphinx config file, and also rewrite Gitbook's SUMMARY.md as sphinx toctrees.

Aesthetics

We can control the look by picking a theme off https://sphinx-themes.org/ and adding custom CSS to it.

Table of Contents (Primary and Secondary)

I also looked around and found a sphinx theme that is almost identical to the Gitbook theme: https://sphinx-book-theme.readthedocs.io/. You can see, it has the same left/right primary/secondary ToC sidebar setup:

layout demo

I'm prototyping this theme right now on neuropoly-docs#ng/sphinx

Edit on Github

That theme comes with a working Edit on Github button:

edit on github

(in fact, most doc themes for sphinx or any other static site generator do this because it's such a common need; and doubly so for docs hosted on RTD, including https://spinalcordtoolbox.com/, because RTD overlays its own Edit button, though it's 3 clicks instead of 1:

so if we pick a static site generator we don't need to fear about losing the Edit button
)

Hosting

We can either host the results with readthedocs as we do elsewhere or directly to github-pages; there's an example of the latter at https://github.com/serra/sphinx-with-markdown/blob/3a6df64976e5e9f55a24625c224071ebd916b9b2/.github/workflows/main.yml#L33 (and in this case I kind of prefer this option, even though yes, it means more Github lock-in; but it's just more self-contained).


Pros of Readthedocs

  • supports multiple branches, for work-in-progress comparison

Pros of Github pages

  • super simple
  • integrated into our workflow directly
  • no extra admin accounts to manage

Cons of Github Pages

  • a bit touchy and maybe underdocumented; CNAME and .nojekyll could have been more clearly explained in their docs...
  • uses a CDN, so sometimes updates won't go live for 10+ minutes

@jcohenadad
Copy link
Member

I'm prototyping this theme right now on neuropoly-docs#ng/sphinx

cool! where can we see it rendered? or do we need to build locally?

@jcohenadad
Copy link
Member

ps: another cons of gitbook is the impossibiliy (for now) to embed objects like google calendars (is that possible with sphinx?)

@kousu
Copy link
Member Author

kousu commented Oct 26, 2021

You need to build locally at the moment:

https://github.com/neuropoly/neuropoly-docs/blob/1efe9e5c1c1db9dcd7e5fcbc92ac2130389d48d9/setup.py#L2-L5

it's still missing

  • primary table of contents
  • automatic publishing

give me 20 minutes though and I can probably knock off that first one, which is the main issue left.

I'm not sure about embedding calendars! But sphinx is very widely used and flexible so surely there's a plugin somewhere for those sorts of use cases.

@kousu
Copy link
Member Author

kousu commented Oct 26, 2021

I also think we should re-merge https://github.com/neuropoly/neuropoly-docs/ and https://github.com/neuropoly/neuropoly-internal-docs/. And maybe rename the latter section "Lab Manual"?

They were only split up because the table of contents got too dense, I believe, but with html_sidebars we should be able to control it so that under "Lab Manual" the top lever ToC is hidden. section we jump down to a different sidebar.

e.g. most pages look like https://sphinx-book-theme.readthedocs.io/en/latest/customize/index.html

Screenshot 2021-10-26 at 14-47-41 Customization

but under blog/ you instead get

Screenshot 2021-10-26 at 14-46-44 Post 2

This is done with this snippet:

https://github.com/executablebooks/sphinx-book-theme/blob/519cf7c78c9ecffdd073be680af8f8f60bb0b130/docs/conf.py#L79-L91

I haven't explored this at all yet but I think there's a 70% chance it will work out.

@jcohenadad
Copy link
Member

@kousu there are a lot of considerations here which only you and me are seeing-- at the end we need to make a consensus decisions among the 30+ members of the lab-- problem: people don't follow this GH thread-- solution: can you pls sum up some points and present at our next lab meeting? (and slack to get ppl attention)-- thx

@kousu

This comment has been minimized.

@kousu

This comment has been minimized.

@kousu
Copy link
Member Author

kousu commented Oct 27, 2021

Performance comparison:

the "Team" page on Gitbook https://www.neuro.polymtl.ca/team takes almost 10MB and 14s and 56 HTTP calls to load.

Screenshot from 2021-10-26 20-04-39

the sphinx version is 1MB, 8.15s in 39 calls:

Screenshot from 2021-10-26 20-04-25

1MB and 39 calls are still quite a lot!! Fully a quarter of the size is loading MathJax.js, which we do not and probably won't use. But it's obviously, well, 10x better in bandwidth and 50% better in speed. But 39 is still..quite a lot

@kousu

This comment has been minimized.

@kousu
Copy link
Member Author

kousu commented Oct 27, 2021

I've got a demo posted to https://wiki-sphinx-demo1.neuropoly.org/:

2021-10-27-020203_1916x1041_scrot

It's hosted at Github Actions via https://github.com/kousu/neuropoly-docs-demo/tree/gh-pages. And it even has SSL:

2021-10-27-020218_1920x1080_scrot

I'll try to get it hosted in this repo next. Hopefully I can do that without actually merging #21; I think merging it would confuse Gitbook and lead to sadness if we're not ready.

Deploying to https://wiki-demo.neuropoly.org

  1. Go to https://ap.www.namecheap.com/Domains/DomainControlPanel/neuropoly.org/advancedns, add

    CNAME wiki-demo.neuropoly.org -> neuropoly.github.io

    Screenshot 2021-10-27 at 02-20-02 Advanced DNS

  2. Push

    https://github.com/neuropoly/neuropoly-docs/blob/a7af67673df75136f95d7e61f60b4da09e40e3ae/.github/workflows/publish.yml#L1

    https://github.com/neuropoly/neuropoly-docs/blob/a7af67673df75136f95d7e61f60b4da09e40e3ae/conf.py#L30-L31

    https://github.com/neuropoly/neuropoly-docs/blob/a7af67673df75136f95d7e61f60b4da09e40e3ae/CNAME#L1

    https://github.com/neuropoly/neuropoly-docs/blob/a7af67673df75136f95d7e61f60b4da09e40e3ae/conf.py#L71

  3. Trigger the workflow manually at https://github.com/neuropoly/neuropoly-docs/actions/workflows/publish.yml...except this doesn't work (buggy?) so instead

  4. Edit it with

    f423f3b

  5. Watch the build here https://github.com/neuropoly/neuropoly-docs/actions/runs/1388886769

  6. Archive the log here: logs_1.zip

  7. Verify the build at https://github.com/neuropoly/neuropoly-docs/tree/gh-pages

    Screenshot 2021-10-27 at 02-27-57 Build software better, together

  8. Go to https://github.com/neuropoly/neuropoly-docs/settings/pages to see what Github thinks about that

  9. Fix the error

    Screenshot 2021-10-27 at 02-27-23 Build software better, together

    by setting

    Screenshot 2021-10-27 at 02-29-09 Build software better, together

    (I'm not sure if this is the right thing to do? It's a bit weird because github is conflating its Jekyll settings with its Hosting settings)

  10. Watch the custom domain fill itself in from the CNAME file, and wait for a cert from letsencrypt to get provisioned:

    Screenshot 2021-10-27 at 02-29-51 Build software better, together

  11. Enforce HTTPS (requires reloading the settings page; minor github glitch)

    Screenshot 2021-10-27 at 02-30-56 Build software better, together

  12. Do we believe this?

    Screenshot 2021-10-27 at 02-31-34 Build software better, together

    No:

    2021-10-27-023210_933x696_scrot

    The other site did this too. It took a few minutes to get around to fully provisioning the working LetsEncrypt cert.

  13. Twiddle thumbs.

  14. Check again: it works!

    2021-10-27-023540_1581x859_scrot

@kousu
Copy link
Member Author

kousu commented Nov 3, 2021

I stumbled into one of the bugs I predicted with Gitbook's git importer:

  • I tried to clean up the Teams page by removing the redundant Table of Contents. Teams page already serves as a kind of table of contents, but since not everyone has a profile page with us -- many just linked their Githubs or LinkedIns -- the formal ToC is confusingly sparse.

    e.g. this is redundant

    2021-11-02-233447_1389x349_scrot

    this is better

    2021-11-02-233230_1364x394_scrot

  • But this broke the links to profiles we do have locally. All of them just go to /team itself now:

    2021-11-02-233720_549x161_scrot

  • I reverted but now while the ToC is back, the links are not:

    2021-11-02-232829_578x413_scrot

    because internally, they're tracking links with a separate data structure from what's being fed in from markdown/git. Because Gitbook isn't actually git-based at all anymore.

  • I don't know how to get the links back besides manually re-entering all of them on app.gitbook.com


I fixed it up manually by doing this for every broken link:

2021-11-02-233948_173x100_scrot

2021-11-02-233958_390x106_scrot

2021-11-02-234001_284x108_scrot

in two patches; producing 8f9e723 then fd1834f. Together they made no changes to this repo at all; but something changed internally on Gitbook.com because now the links work again:

2021-11-02-234515_431x180_scrot

gitbook-com bot pushed a commit that referenced this issue Nov 3, 2021
@kousu kousu mentioned this issue Nov 3, 2021
@kousu
Copy link
Member Author

kousu commented Nov 3, 2021

Another export bug: table headers don't export correctly.

Gitbook (and Markdown) have optional table headers (written <thead> in HTML):

2021-11-03-000108_799x220_scrot

but we're not using them anywhere:

2021-11-03-000317_876x512_scrot

i.e. we have "Show table header" unchecked everywhere:

2021-11-03-000343_834x242_scrot

however when exported, Gitbook ignores this checkbox and just exports the first row as a header anyway, placing the ---- row in to mark it:

2021-11-03-000430_957x280_scrot
2021-11-03-000436_335x625_scrot

So the only safe way is to always keep the headers turned on. I bet that's how ended up with all those redundant "Name" rows on that page in the first place, maybe during the migration to their newest version they ran our repo in and out of their exporter a few times....

EDIT: I partially take this back: table headers are mandatory in Github-flavoured markdown. But Gitbook is still doing it wrong by exporting the first row of content as that header, in the case where you have headers hidden on its side.

@kousu kousu closed this as completed in #21 Nov 18, 2021
@kousu kousu added bug Something isn't working supporting infrastructure Scripts, CI, build tools, hosting theme Layout, CSS, HTML, colour scheme, etc labels Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working supporting infrastructure Scripts, CI, build tools, hosting theme Layout, CSS, HTML, colour scheme, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants