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

Asciidoctor to ReST doc conversion #3033

Merged
merged 3 commits into from Jul 25, 2020
Merged

Conversation

gonsie
Copy link
Contributor

@gonsie gonsie commented Jul 6, 2020

Start of conversion for core documentation.

I’ll need some help integrating sphinx and such into the build system... all I’ve done thus far is remove the asciidoctor checks.

@gonsie gonsie changed the title Asciidoctor to ReST doc conversion WIP: Asciidoctor to ReST doc conversion Jul 6, 2020
@grondo
Copy link
Contributor

grondo commented Jul 7, 2020

Thanks! I can try to help integrate sphinx or whatever is required on the build system side of things.

You will also need to remove doc/man*/Makefile from configure.ac along with the No asciidoctor formatter warning (or we can do that. We still may want to allow the rest of flux-core to build without generated docs, and keep the warning) Though I'm not sure how the generated man pages will get installed at make install time without Makefiles?

Did COPYRIGHT inclusion get dropped on purpose in man pages? (I notice some other includes were preserved)

Copy link
Member

@SteVwonder SteVwonder left a comment

Choose a reason for hiding this comment

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

Thanks @gonsie for putting this together! You rock!

Did a quick pass (haven't run/compiled it yet) and it looks good! One minor comment below.

doc/conf.py Outdated Show resolved Hide resolved
@gonsie
Copy link
Contributor Author

gonsie commented Jul 7, 2020

@grondo This PR definitely was a rough start and I wasn’t sure the exact use-case that would need to be supported. I think the basic use case is: If the ‘enable docs’ option is on, then the docs should be built and installed with make install. Are there any others?

The copyright statement at the bottom of the man pages is generated & inserted by sphinx. Actually, the author statement is inserted as well, I’ll go and remove those.

@gonsie
Copy link
Contributor Author

gonsie commented Jul 7, 2020

One other use case is that the man pages get generated for the readthedocs website (duh!). Any others?

@SteVwonder
Copy link
Member

One other use case is that the man pages get generated for the readthedocs website (duh!). Any others?

As a small addendum to this use case, I think it would be cool if we could have the RTD CI run on flux-core PRs like it does for the rfc and docs repos. I'm not sure if we just need make html to pass through to sphinx, or if there is something more going on in the RTD CI. We probably need a requirements.txt if we don't already have one.

@gonsie
Copy link
Contributor Author

gonsie commented Jul 7, 2020

@SteVwonder the travis.yaml file is super complex here... any idea where to start? maybe we can get together on friday to hack it out. :\

@gonsie
Copy link
Contributor Author

gonsie commented Jul 8, 2020

Question: which NAME section style do you prefer? Style 1 includes the other command that share the same man page text, style 2 just has the current man page name. The original style (included) is not possible with sphinx.

# Style 1
NAME
       flux-getattr - flux-getattr, flux-setattr, flux-lsattr - access broker attributes

# Style 2
NAME
       flux-getattr - access broker attributes

# Original
NAME
       flux-getattr, flux-setattr, flux-lsattr - access broker attributes

@SteVwonder
Copy link
Member

Question: which NAME section style do you prefer?

What would the NAME section for the flux-lsattr manpage be in style 2?

NAME
    flux-lsattr - access broker attributes

OR

NAME
    flux-getattr - access broker attributes

@gonsie
Copy link
Contributor Author

gonsie commented Jul 8, 2020

For both styles, the flux-lsattr name would come first on that man page.

Basically the Sphinx generation puts “name - description” on this line, it just depends if we include the other related commands in the “description” text.

@grondo
Copy link
Contributor

grondo commented Jul 8, 2020

One other use case is that the man pages get generated for the readthedocs website (duh!). Any others?

I can't think of any. A finer point: the man pages should be generated with make and installed with make install. If you run src/cmd/flux help command|function in the build dir, the MANPATH is constructed such that you should get the manpage from the build tree (i.e. the manpage that goes with the version of flux you are running)

@SteVwonder
Copy link
Member

For both styles, the flux-lsattr name would come first on that man page.

Awesome! In that case, my vote is for style 2 since it is cleaner.

@grondo
Copy link
Contributor

grondo commented Jul 11, 2020

We should try to get this merged asap, so that we won't have to keep rebasing it as new or changed documentation lands in flux-core.

Is there an option in the conversion process from adoc->rst to keep the line breaks from the source material? At least the files I spot checked, paragraphs end up all on one line. This might not be conducive to reviewing
future changes, since a single change in a paragraph will create a diff that involves the whole single-line paragraph.

I'll try to take a look at getting sphinx run (when found) with make, and the docs installed with make install. I wonder if sphinx is already available in the TOSS buildfarm. (I hope so)

@SteVwonder
Copy link
Member

I'll try to take a look at getting sphinx run (when found) with make, and the docs installed with make install.

Sorry for not posting a commit yesterday. I have a half-way baked Makefile.am in the works from the doc day call yesterday. I'll try and get it working in the next hour or so.

It's pretty much a copy paste from the old Makefile.am that used asciidoc, except it is lifted up one directory and has adoc replaced for rst.

getting sphinx run (when found)

As long as we are OK requiring that the python that flux-core is configured against is the same python that has the sphinx module, I think we can treat it exactly like the other python dependencies. I was thinking we can use the AM_CHECK_PYMOD m4 macro to check the module version is > 1.6.7 (where 1.6.7 is the version in the bionic package repo). And we shouldn't need to locate the sphinx_build since it can be run via the configured python interpreter with $(PYTHON) -m sphinx SPHINX_ARGS.

I just gotta figure out the right automake syntax that supports "recursive" commands that can generate everything in one go, as opposed to compilers/asciidoc that can be run with one input file and produce one output file.

Copy link
Member

@SteVwonder SteVwonder left a comment

Choose a reason for hiding this comment

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

Couple of small grammar nits that I noticed in a quick read through.

doc/README.md Outdated Show resolved Hide resolved
doc/README.md Outdated Show resolved Hide resolved
@grondo
Copy link
Contributor

grondo commented Jul 11, 2020

I just gotta figure out the right automake syntax that supports "recursive" commands that can generate everything in one go, as opposed to compilers/asciidoc that can be run with one input file and produce one output file.

This is the main issue I was anticipating. Thanks a lot for taking this on!! I didn't have time to look at it yet, but will happily test 😜

@SteVwonder
Copy link
Member

SteVwonder commented Jul 11, 2020

Just pushed two commits to a branch on my fork: https://github.com/SteVwonder/flux-core/commits/rst-docs

They works for generating the manpages with make. I haven't tested make install or make distcheck. Calling it for the weekend. I can revisit next week unless someone else wants to push it forward. If run make in the doc directory, it will run sphinx multiple times because it is looking for manpages for idset_*, which somehow got dropped in this conversion. If you comment out those manpages in the doc/Makefile.am, then sphinx only gets run once. The trick was this target:

$(MAN_FILES): $(RST_FILES)
    $(AM_V_GEN) $(PYTHON) -m sphinx -M man ./ ./

@gonsie gonsie force-pushed the rst-docs branch 3 times, most recently from 24de6b1 to 5f61fac Compare July 16, 2020 21:36
@gonsie
Copy link
Contributor Author

gonsie commented Jul 16, 2020

@SteVwonder @grondo I think this branch is working!

@SteVwonder
Copy link
Member

SteVwonder commented Jul 16, 2020

Thanks @gonsie for all the work on this PR! You are awesome! 🥇


I am getting an error when building the whole project. The gen-cmdhelp.pl script seems to have references to .adoc. I'm not sure exactly what is going on in the script (it looks like it outputs a json mapping of commands->manpages similar to what is in conf.py). Maybe @garlick or @grondo can comment on exactly what is happening, and if it is even necessary anymore since Sphinx generates a full manpage for each target rather than just so links.

❯ make
<snip>
  CC       flux-queue.o
  CCLD     flux-queue
  CC       flux-exec.o
  CCLD     flux-exec
make[3]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/src/cmd'
make[2]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/src/cmd'
Making all in test
make[2]: Entering directory '/data/hdd/Repositories/flux-framework/flux-core/src/test'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/src/test'
make[2]: Entering directory '/data/hdd/Repositories/flux-framework/flux-core/src'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/src'
make[1]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/src'
Making all in etc
make[1]: Entering directory '/data/hdd/Repositories/flux-framework/flux-core/etc'
  GEN      flux/help.d/core.json
Usage: ./gen-cmdhelp.pl --category=[label] FILES...
make[1]: *** [Makefile:830: flux/help.d/core.json] Error 255
make[1]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/etc'
make: *** [Makefile:574: all-recursive] Error 1

All sorts of weirdness happens in doc when run under make -j (sorry for not catching that earlier). Using .NOTPARALLEL seems to fix the issue:

diff --git a/doc/Makefile.am b/doc/Makefile.am
index 466747c1f..3bb863d1b 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,5 @@
+.NOTPARALLEL:
+
 SUBDIRS = . test

 MAN_FILES = $(MAN1_FILES) $(MAN3_FILES) $(MAN5_FILES) $(MAN7_FILES)

It looks like configure didn't find aspell. Maybe the aspell code snippet in configure.ac needs to get added back in?

❯ make check
<snip>
make[2]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/doc'
make[1]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/doc'
Making check in test
make[1]: Entering directory '/data/hdd/Repositories/flux-framework/flux-core/doc/test'
make  check-TESTS
make[2]: Entering directory '/data/hdd/Repositories/flux-framework/flux-core/doc/test'
make[3]: Entering directory '/data/hdd/Repositories/flux-framework/flux-core/doc/test'
SKIP: spellcheck - skip because aspell is not installed
============================================================================
Testsuite summary for flux-core 0.17.0-101-g5f61facdd
============================================================================
# TOTAL: 1
# PASS:  0
# SKIP:  1
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
make[3]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/doc/test'
make[2]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/doc/test'
make[1]: Leaving directory '/data/hdd/Repositories/flux-framework/flux-core/doc/test'

sherbein ~/Repositories/flux-framework/flux-core/doc (rst-docs !?S)
❯ which aspell                                                                                                              14:49:43 ()
/usr/bin/aspell

(1) sherbein ~/Repositories/flux-framework/flux-core (rst-docs !?S)
❯ grep aspell configure.ac config.log || echo "no matches found"                                                                         14:51:09 ()
no matches found

@gonsie
Copy link
Contributor Author

gonsie commented Jul 16, 2020

Looks like gen-cmdhelp.pl processes comments from the adoc files (which got dropped in the conversion). It’d be helpful to see the results of the script, so I can figure out if there is an easy way to recreate them with sphinx.

@grondo
Copy link
Contributor

grondo commented Jul 16, 2020

Looks like gen-cmdhelp.pl processes comments from the adoc files (which got dropped in the conversion). It’d be helpful to see the results of the script, so I can figure out if there is an easy way to recreate them with sphinx.

Yeah, that script processes comments in command man pages to determine if commands should be added to the generic flux help summary of "commonly used commands".

[
  {
    "category": "core",
    "command": "broker",
    "description": "Invoke Flux comms message broker daemon"
  },
  {
    "category": "core",
    "command": "content",
    "description": "Access instance content storage"
  },
  {
    "category": "core",
    "command": "cron",
    "description": "Schedule tasks on timers and events"
  },
  {
    "category": "core",
    "command": "dmesg",
    "description": "manipulate broker log ring buffer"
  },
  {
    "category": "core",
    "command": "env",
    "description": "Print or run inside a Flux environment"
  },
  {
    "category": "core",
    "command": "event",
    "description": "Send and receive Flux events"
  },
  {
    "category": "core",
    "command": "exec",
    "description": "Execute processes across flux ranks"
  },
  {
    "category": "core",
    "command": "get,set,lsattr",
    "description": "Access, modify, and list broker attributes"
  },
  {
    "category": "core",
    "command": "hwloc",
    "description": "Control/query resource-hwloc service"
  },
  {
    "category": "core",
    "command": "jobs",
    "description": "list jobs submitted to Flux"
  },
  {
    "category": "core",
    "command": "keygen",
    "description": "generate keys for Flux security"
  },
  {
    "category": "core",
    "command": "kvs",
    "description": "Flux key-value store utility"
  },
  {
    "category": "core",
    "command": "logger",
    "description": "create a Flux log entry"
  },
  {
    "category": "core",
    "command": "mini",
    "description": "Minimal Job Submission Tool"
  },
  {
    "category": "core",
    "command": "module",
    "description": "manage Flux extension modules"
  },
  {
    "category": "core",
    "command": "ping",
    "description": "measure round-trip latency to Flux services"
  },
  {
    "category": "core",
    "command": "proxy",
    "description": "Create proxy environment for Flux instance"
  },
  {
    "category": "core",
    "command": "start",
    "description": "bootstrap a local Flux instance"
  },
  {
    "category": "core",
    "command": "version",
    "description": "Display flux version information"
  }
]

@grondo
Copy link
Contributor

grondo commented Jul 16, 2020

Can we just add the comments back to the source material?

@gonsie gonsie force-pushed the rst-docs branch 2 times, most recently from 578510c to 7ea6860 Compare July 17, 2020 00:01
@gonsie
Copy link
Contributor Author

gonsie commented Jul 17, 2020

@grondo I added back the comments, but there is something buggy about gen-cmdhelp.pl script. When I run it I get the error:

Use of uninitialized value $h{"command"} in printf at ./gen-cmdhelp.pl line 68

Can you check out the last commit I pushed (7ea6860) and see if you can figure out if anything is wrong?

@grondo
Copy link
Contributor

grondo commented Jul 22, 2020

I ran into an issue testing this out in a VPATH build. (sphinx SRCDIR was listed as . instead of $(srcdir)). Also, I noticed conf.py wasn't added to Makefile.am, so this file would likely not be included in make distcheck.

Finally, "quiet mode" make wasn't working because sphinx spews a lot of gak by default.

And lastly, some manpages were mentioned twice and this generated automake warnings.

This patch should fix all that up:

diff --git a/doc/Makefile.am b/doc/Makefile.am
index 3bb863d1b..41fa5c2fa 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -196,7 +196,6 @@ MAN3_FILES_SECONDARY = \
        man/flux_future_wait_for.3 \
        man/flux_future_reset.3 \
        man/flux_future_destroy.3 \
-       man/flux_future_get.3 \
        man/flux_future_fulfill.3 \
        man/flux_future_fulfill_error.3 \
        man/flux_future_fulfill_with.3 \
@@ -204,13 +203,11 @@ MAN3_FILES_SECONDARY = \
        man/flux_future_aux_get.3 \
        man/flux_future_set_flux.3 \
        man/flux_future_get_flux.3 \
-       man/flux_future_wait_all_create.3 \
        man/flux_future_wait_any_create.3 \
        man/flux_future_push.3 \
        man/flux_future_first_child.3 \
        man/flux_future_next_child.3 \
        man/flux_future_get_child.3 \
-       man/flux_future_and_then.3
        man/flux_future_or_then.3 \
        man/flux_future_continue.3 \
        man/flux_future_continue_error.3 \
@@ -282,10 +279,19 @@ endif
 
 SUFFIXES = .rst .1 .3 .5 .7
 
-$(MAN_FILES): $(RST_FILES)
-       $(AM_V_GEN) $(PYTHON) -m sphinx -M man ./ ./
+sphinx_verbose = $(sphinx_verbose_$(V))
+sphinx_verbose_ = $(sphinx_verbose_$(AM_DEFAULT_VERBOSITY))
+sphinx_verbose_0 = @echo "  SPHINX    manpages";
+
+STDERR_DEVNULL = $(stderr_devnull_$(V))
+stderr_devnull_ =  $(stderr_devnull_$(AM_DEFAULT_VERBOSITY))
+stderr_devnull_0 = >/dev/null 2>&1
+
+$(MAN_FILES): conf.py $(RST_FILES)
+       $(sphinx_verbose)$(PYTHON) -m sphinx -M man $(srcdir) ./ $(STDERR_DEVNULL)
 
 EXTRA_DIST = \
+       conf.py \
        $(RST_FILES) \
        man1/NODESET.rst \
        man3/JSON_PACK.rst \

I changed the quiet output to just SPHINX manpages instead of SPHINX man1/flux.1:
I also added conf.py as manpage generation dependency.

make[1]: Entering directory '/home/grondo/git/f.git/build/doc'
  SPHINX  manpages
make[1]: Leaving directory '/home/grondo/git/f.git/build/doc'
Making all in test
make[1]: Entering directory '/home/grondo/git/f.git/build/doc/test'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/grondo/git/f.git/build/doc/test'


@lgtm-com
Copy link

lgtm-com bot commented Jul 24, 2020

This pull request introduces 1 alert when merging b2f00a5 into 7953a1a - view on LGTM.com

new alerts:

  • 1 for Unused import

@grondo
Copy link
Contributor

grondo commented Jul 24, 2020

Ah, one more fix needed here. If sphinx is missing ./configure fails. I'll try to reestablish the previous behavior of just disabling doc generation.

@grondo
Copy link
Contributor

grondo commented Jul 24, 2020

Ok, replaced a AC_MSG_ERROR with AC_MSG_WARN, and added back the other WITH_DOCS logic to configure.ac. This should be ready now! I'll go ahead an build new docker images and test just to be sure.

@gonsie
Copy link
Contributor Author

gonsie commented Jul 24, 2020

👏🏼👏🏼👏🏼thanks @grondo !!

@grondo
Copy link
Contributor

grondo commented Jul 24, 2020

thanks @grondo !!

We would have never been able to get this done without you @gonsie! Thanks so much for all the tedious work!

@garlick
Copy link
Member

garlick commented Jul 24, 2020

Thanks everybody! I'm excited to see how these look.

@grondo
Copy link
Contributor

grondo commented Jul 24, 2020

Have to rebase again since #3068 went in.

@grondo grondo force-pushed the rst-docs branch 2 times, most recently from 53ed608 to 6f4a2e1 Compare July 25, 2020 00:17
gonsie and others added 3 commits July 25, 2020 00:29
Update all manpage docs to reST from asciidoc.

Convert all manpages, tools, autotools dependencies, etc.  This is done
all in one commit to avoid breaking the build with intermediate work.

Summary of changes:

 - Auto-convert all adoc manpages to .rst and manually fix any issues

 - Move Author, Description, and NAME sections out of manpage source,
   this is handled in sphinx conf.py

 - By default, Sphinx wants to output all manpages in a single dir.
   To allow MANPATH in a build dir to work correctly, add a rule to
   move manpages to man1/, man3/, etc. after sphinx build to preserve
   compatibility with manpath.

 - Replace gen-cmdhelp.pl with a Python version, which uses sphinx's
   conf.py to assist in processing manpage sources.

 - Update autotools to look for sphinx deps instead of asciidoctor

Co-authored-by: Stephen Herbein <stephen272@gmail.com>
Co-authored-by: Mark A. Grondona <mark.grondona@gmail.com>
Prepare for conversion to sphinx for documentation.

Remove ruby and asciidoctor, add sphinx and other deps.
@SteVwonder
Copy link
Member

Thanks @gonsie and @grondo for all the effort on this. 🥳 👏 🙌 🍾 🥂 🍰

I'm excited to see how these look.

Same! It is going to be 🔥 to have our manpages up on readthedocs.

@grondo
Copy link
Contributor

grondo commented Jul 25, 2020

In the process of pushing up the new docker images. Then this is officially ready for merge.

@codecov-commenter
Copy link

Codecov Report

Merging #3033 into master will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #3033   +/-   ##
=======================================
  Coverage   81.19%   81.20%           
=======================================
  Files         285      285           
  Lines       44229    44229           
=======================================
+ Hits        35912    35916    +4     
+ Misses       8317     8313    -4     
Impacted Files Coverage Δ
src/modules/job-archive/job-archive.c 58.89% <0.00%> (-0.80%) ⬇️
src/common/libsubprocess/local.c 79.59% <0.00%> (-0.35%) ⬇️
src/broker/broker.c 74.89% <0.00%> (-0.11%) ⬇️
src/modules/job-info/guest_watch.c 76.72% <0.00%> (+0.57%) ⬆️
src/broker/modservice.c 72.18% <0.00%> (+0.75%) ⬆️
src/broker/module.c 76.07% <0.00%> (+1.12%) ⬆️

Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

I'll add an approval here given that @gonsie and @grondo have been all over this and I trust them. MWP for the win?

@grondo
Copy link
Contributor

grondo commented Jul 25, 2020

CI is now all green. @garlick gave an approval, @SteVwonder want to take a look too or shall we set MWP?

@grondo
Copy link
Contributor

grondo commented Jul 25, 2020

Sorry @garlick, we cross posted. I'm ready to set MWP. We can fix up any fallout as we go along.

@SteVwonder
Copy link
Member

MWP is fine with me. I agree, let's fix stuff in a follow up PR if anything is broken. Kinda confused why we aren't seeing the RTD's CI builder check thingy. I thought we added the webhook. I'll poke at that.

@grondo
Copy link
Contributor

grondo commented Jul 25, 2020

Oh, yeah I meant to ask about that. I didn't see anything that pushes the built docs to RTD. (Though I didn't look carefully, was mainly concentrating on getting the conversion done so we don't conflict with future manpage updates.)

@grondo
Copy link
Contributor

grondo commented Jul 25, 2020

MWP set!

@mergify mergify bot merged commit 53cf4b1 into flux-framework:master Jul 25, 2020
@grondo
Copy link
Contributor

grondo commented Jul 25, 2020

Thanks @gonsie and @SteVwonder!! 👏

@SteVwonder
Copy link
Member

YAY!!!!!!! 🥳

Per the RTD CI check, the webhook was working just fine. The issue was that the builder for PRs wasn't enabled in the Advanced Settings: https://docs.readthedocs.io/en/stable/guides/autobuild-docs-for-pull-requests.html. I flicked that on, hopefully it works now. 🤞

I also took the liberty of updating some RTD settings like where it looks for the conf.py and the requirements.txt. FWIW, if we need to tweak those setting in the future, we can do so with Yet Another Dotfile at the Top-Level of the Repo (YADTLR™️): https://docs.readthedocs.io/en/stable/config-file/v2.html

@grondo
Copy link
Contributor

grondo commented Jul 25, 2020

Great, thanks! It is working

https://flux-framework.readthedocs.io/projects/flux-core/en/latest/man1/flux-jobs.html

One thing I notice is that on the left sidebar all the commands are listed in caps, e.g. FLUX-JOBS(1). Just something minor to fixup later.

@garlick
Copy link
Member

garlick commented Jul 25, 2020

Looks great! One other nice to have would be inline manpage references working as links, but probably for another time. Nice work everybody!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants