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

Begin new odoc manuals #203

Merged
merged 4 commits into from
Oct 12, 2018
Merged

Begin new odoc manuals #203

merged 4 commits into from
Oct 12, 2018

Conversation

leostera
Copy link
Collaborator

@leostera leostera commented Sep 26, 2018

Opening this to gather early feedback and comments 🗣

I feel it's mandatory for odoc, since it's goal is to generate documentation, to bootstrap it's own. So odoc is documented using odoc.

Hence I'm opening this PR. I started writing a new index manual, but i'd like a few more things to get done before we merge it.

For the time being I'm hosting it here: https://ostera.github.io/odoc/

TO DO

  • Scaffold Manuals
    • Index + Getting Started
    • High-level overview of odoc
    • Using odoc
    • Odoc Internals: In-depth flow of compilation
    • Build System Integration
    • Contributing to odoc
  • Automatically publish docs to Github Pages
  • make docs
  • Build docs on CI

Follow-up Work

  • Point .md files in repo to docs
  • Make sure all references to the modules are correct
  • Make sure all flows are correct
  • Proofread
  • Table of Contents is generated
  • Odoc Internals: In-depth flow of html generation

@leostera
Copy link
Collaborator Author

cc @aantron @rizo

@@ -0,0 +1,252 @@
{1:top odoc}

The documentation compiler for OCaml, Reason, and BuckleScript.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does BuckleScript belong here? You could as well say dune in that case. Any tool can use odoc really, I'd keep just "OCaml and Reason".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we convey properly that this can be used with BuckleScript compilation units, I'm up for rephrasing.

It's not obvious to everyone, particularly since Reason can be used with the OCaml toolchain.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be explained later, i.e., the fact that odoc is designed to be integrated into existing build toolchains like BuckleScript and dune. A "documentation compiler" operates on syntax; BuckleScript is a compiler, that's why I find it confusing.

Also, ideally the end users shouldn't worry about how odoc works at all. That's why I think it's important to have a separate guide that describes the documentation features for documentation authors.


{2:overview What is [odoc] really?}

[odoc] is not your regular documentation tool.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd mention that it's designed to be build-tool friendly. With focus on parallelism, caching, etc. I don't mind adding those changes separately though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than "regular" I'd say "ordinary". We hope it becomes everyone's regular tool. :)

|> map ~f:compile_to_odoc (* here we have Game.odoc, Player.odoc, etc *)
|> iter ~f:compile_to_html (* here we have Game/index.html, and so on *)

]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to show this in shell syntax? Otherwise people will assume there's actually an OCaml API for this.

on compiler outputs and turns them into compiled documentation, which then
becomes gorgeous HTML.

A regular [odoc] execution transforms [cmt], [cmti], and [mld] files into [odoc]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can explain what odoc files are before mentioning them here? Surely people will ask "what is an odoc file?".


{[
# We must tell odoc what the name of this Package is!
λ odoc compile --package Game -o ./src/Player.odoc ./src/Player.cmti
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor thing, but $ would look more familiar to most people.

Now we can compile this to an HTML file:

{[
λ odoc html -I src -o . ./src/Player.odoc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -o is very important. I would explain that it's typically the root path of the generated documentation for a package.

@rizo
Copy link
Collaborator

rizo commented Sep 26, 2018

Don't have time to do a thorough review but I like the idea in general.

I would try to clarify who is the target audience for the manual sections. For example, the low-level compilation information is IMO only useful for people who need to integrate odoc into a build tool – I would try to make it more formal and less example-driven.

Alternatively, for end users, it's more important to know how to write good documentation with the available features (pages, indexes, references, etc).

@grabbou
Copy link

grabbou commented Sep 26, 2018

Thank you very much for taking care of this! If there's anyway I can help or get involved, please let me know!

It took me a really long time to figure out the process of building a documentation website with odoc. Great that it will be all in one place from now.

Alternatively, for end users, it's more important to know how to write good documentation with the available features (pages, indexes, references, etc).

I can only speak for myself, but I wish I knew all that upfront.

@aantron
Copy link
Contributor

aantron commented Sep 26, 2018

Agreeing with @rizo here, the text so far is for people doing build system integration (and we do need that text). Hopefully, fewer and fewer end users will need to see this over time. odoc developers will always need this.

@rizo
Copy link
Collaborator

rizo commented Sep 27, 2018

One extra comment about the name change from index.mld to page-index.mld: dune treats the index.mld file in a special way – it's used to produce the module index page. For that reason and because the page-* prefix is only required for .odoc files I don't recommend renaming the file. Thus for consistency other documentation pages should also avoid the prefix. I also find it redundant anyway, the fact that the file is a page is already clear from the extension.

@leostera leostera mentioned this pull request Oct 8, 2018
13 tasks
@leostera
Copy link
Collaborator Author

leostera commented Oct 9, 2018

I split the manual into smaller pieces that we can extend independently over time: https://ostera.github.io/odoc/Odoc/

However, I don't expect this PR to elaborate on all of them immediately, so I'll mark the Manuals in the TODO list as done.

Over the next few days I'll get the build+publish process in place, and then we can review more easily.

@leostera
Copy link
Collaborator Author

leostera commented Oct 9, 2018

@aantron @rizo thoughts on running make docs on every commit? pre-commit hook that can be setup? keep it manual for now?

If we keep it manual and use the master branch's docs folder then I can check those two TODO's off ✅

@leostera
Copy link
Collaborator Author

leostera commented Oct 9, 2018

I included the necessary travis config to build and deploy on every commit that makes it to master. It's straightforward to drop if we decide to manually publish docs 👍

.travis.yml Outdated
@@ -8,6 +8,8 @@ env:
- OCAML=4.05.0
- OCAML=4.06.1
- OCAML=4.07.0
global:
secure: jMXf4/x4WZdgYARkH9CEq/zk58fPhiRzUwysBzSSA1f+tb8uRGNaMukZ41tdCsTdH2AckVw8Q5CHDD8RZCtAwftZjOHjjocvPlRtCEtXwy9qri5+a9g3dqMj/0WMW4YUt0Z9oSAXfjObL7vKKTNUx/aZASLx9+vLJNGUYVfhtOWVBiWc9PuAaE+TYKcE4gY43OihgpEy2QK/O/wSkfY2eaf7rsWGMSS/re2dtaBsl9CS2Z8IcWarSfl9+KajDejU2ciTfKwK5JKGx6pSG6We3qj7hNl+zRQJCXsEVflqon8/K/HReFbwoFJ4iRcs3lAQ56sVKzYhhLyCKbGywgZPl3GmhwM+NSLpWeh9KQTbkBEQFK+8J6qRWSYsjaZktbIZIOjYRf+rAwSRdmRnI3rNppP02oxTgi5fBZV+t+3SjLsHZqfzutuAphED23Pj2nu0GUABNzFYV+XkracZFiiTQeWPb5iH2SC334pL+KmY6Dsp8JyP2Kq8NpOsZo8085368Nlkr2EERSrhWeO/bo0kNE9c+/Q8JWmyhSYMwAaglnACudCqNCW2g7lFMUn8p18TrEZsS/wegNXf7MMRmFV5AT8zMR2v2ZGRjJRXFY6hP0Eq4G3TnkQGc7SPp/ayv0qqBQZ3UbHBB74+T9ADUCNvfafbrKsXMKAstXf+AZyuMbc=
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aantron I'd feel more comfortable if the $GITHUB_TOKEN was set up in the repo settings, but we can get this running with this token (it currently only has public_repo access) and change it if we like the way the docs are published.

@aantron
Copy link
Contributor

aantron commented Oct 9, 2018

I usually publish docs manually, because we want to leave the version for the last release up until the next release.

If/when odoc supports version switching, we can start publishing the dev docs automatically (and document that, so other projects can do it :) ).

@leostera
Copy link
Collaborator Author

leostera commented Oct 9, 2018

Good insight. Published docs from master may not reflect the latest release 👍 — we don't want that, so I'll drop those commits and rebase on master after people have had some time to review their previous comments.

@leostera
Copy link
Collaborator Author

Alright, rewritten history without automatic publishing.

@aantron can we split this PR so I focus on getting the rest of the TODO's in another one?

@aantron
Copy link
Contributor

aantron commented Oct 11, 2018

Yes, of course. Let me know when this one is ready for review.

@leostera leostera force-pushed the document-flow branch 2 times, most recently from e590734 to a1856d2 Compare October 11, 2018 22:50
@leostera
Copy link
Collaborator Author

The last one point I'll make is about publishing the docs with Github Pages.

I'd prefer if we used the simpler mechanism they offer, where the docs site is hosted within the master branch, inside of the docs folder. This allows for:

  1. Cleaner PRs that update both the code and the documentation in one go
  2. Simpler workflow, where at the end of my changes I can run make docs and commit that with "Update docs".

Alternatively we could publish to gh-pages branch, which would mean an update to documentation will have to come in two steps: a PR to master, and a commit to gh-pages.

If we opt for the latter, then we should have a straightforward way of doing so (a-la, make docs-publish).

@leostera leostera force-pushed the master branch 2 times, most recently from 68eddf2 to 93ae8e0 Compare October 12, 2018 06:39
@aantron
Copy link
Contributor

aantron commented Oct 12, 2018

@Ostera Given we are going with republishing the docs only at release time (and for any serious errata), I think we want to avoid 1 and 2. We don't want PRs to master to affect the published docs, we want to discourage contributors from being misled into trying to republish them, and the publishing workflow is only going to be carried out by whoever is doing the release (in the coming release, myself).

I think we just need instructions for how the generated dosc (in a .gitignored directory) can be reviewed locally.

I suggest to leave the generated docs out of master for now, and we will put them in gh-pages later. I can create the Makefile target for that now, or next week during release cleanup.

@leostera
Copy link
Collaborator Author

Makes sense. There’s a make docs target already, I’ll drop the commit with the docs and add them to .gitignore when I get home 👍🏼

This removes the old manual_usage and refurbishes the main manual of
`odoc` to point to several smaller, more focused ones.

It scaffolds manuals for:

+ System Integrations: where we can explain how it works with `dune`,
`bsb`, `esy`, etc.

+ Internals: where we can dig digger into why are the internal
representations the way they are and how they fit together at great
length.

+ Using Odoc: where we can explain in tutorials how to make the best use
of the features available for documenting interfaces, writing custom
pages, and showcasing what we believe are good docs to get inspired by.

+ A high-level tutorial of how the generation works.

---

It also includes a handy make target that will run in CI.
@leostera
Copy link
Collaborator Author

@aantron should be good now 👍

@aantron
Copy link
Contributor

aantron commented Oct 12, 2018

I see a .swp file committed, perhaps you should remove it? If it might be a problem in the future, maybe we should .gitignore it.

No idea how this came to be. It's a vim swap file for no file.
@leostera
Copy link
Collaborator Author

No idea how that file came to be. It's a swap file from vim, but I can't tie it back to any edited fail. I'll make sure it's ignored globally.

Another small change I couldn't get through (since I already had the folder in place) is that make docs didn't create the folder and thus the copy failed.

Makefile Outdated
@@ -17,6 +17,7 @@ npm-test :

.PHONY : docs
docs :
mkdir docs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this will fail if docs/ already exists, you need mkdir -p docs to avoid that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to stop working late at night. Thanks for catching this 🙌

@aantron aantron merged commit 84e1311 into ocaml:master Oct 12, 2018
@aantron
Copy link
Contributor

aantron commented Oct 12, 2018

Thanks!

@aantron aantron changed the title Documentation for Odoc Begin new odoc manuals Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants