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

Add a contrib/gendocs.py script for generating documentation web site #4997

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

igor-ramazanov
Copy link
Contributor

Hey, I think Kakoune is a great editor!

I struggled with a searchable and mobile-phone friendly documentation.

Here're a Bash and Scala scripts to use the existing **/*.asciidoc
for generating the static website.

The code is far from ideal, but should be a good start.

Would be good to improve the script and automatically publish the
documentation using Github Actions and Pages.

Hosting the draft on my personal Github pages.

Here's how it looks like: https://igor-ramazanov.github.io/.

@igor-ramazanov igor-ramazanov changed the title Fix broken docs link Add a contrib/gendocs.sh script for generating documentation web site Oct 15, 2023
@mawww
Copy link
Owner

mawww commented Oct 23, 2023

Hey, this is great, I am just a bit concerned about the use of scala, I would have preferred a language that almost always available on posix platforms (such as sh/perl/python), but this is contrib/ so I guess it is fine.

@igor-ramazanov
Copy link
Contributor Author

Hi, yes, I would like to remove Scala and use something more standard too.

Tried first with awk, but it was difficult for me as I am not that profficient in it.

Let me check if I can replace Scala with sh/sed/grep/awk!

@krobelus
Copy link
Contributor

Maybe writing the entire script in Python is better than mixing languages. But your call, whatever works

Hey, I think Kakoune is a great editor!

I struggled with a searchable and mobile-phone friendly documentation.

Here're a Bash and Scala scripts to use the existing `**/*.asciidoc`
for generating the static website.

The code is far from ideal, but should be a good start.

Would be good to improve the script and automatically publish the
documentation using Github Actions and Pages.

Hosting the draft on my personal Github pages.

Here's how it looks like: https://igor-ramazanov.github.io.
What: migrate from shell and Scala to pure Python.

Why: to improve the UX as users likely already have Python installed.
@igor-ramazanov
Copy link
Contributor Author

@mawww @krobelus Hi, I've rewritten the script to Python 3.

Now it does not depend on fd, scala-cli, sed and awk, uses only Python 3 and https://antora.org.

  I dedicate any and all copyright interest in this software to the
  public domain.  I make this dedication for the benefit of the public at
  large and to the detriment of my heirs and successors.  I intend this
  dedication to be an overt act of relinquishment in perpetuity of all
  present and future rights to this software under copyright law.
Refactoring:
1. Generate the docs from a single Python file.
2. Run through Blake formatter.
3. Add links to Antora documentation pages.
@igor-ramazanov igor-ramazanov changed the title Add a contrib/gendocs.sh script for generating documentation web site Add a contrib/gendocs.py script for generating documentation web site Dec 28, 2023
# See: https://docs.antora.org/antora/latest/standard-directories.
# https://docs.antora.org/antora/latest/root-module-directory.
os.makedirs("modules/ROOT/images", exist_ok=True)
os.makedirs("modules/ROOT/pages", exist_ok=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW instead of doing an in-tree build that requires renaming of some files,
I'd prefer to creating a separate directory (html_doc?),
copy all asciidoc files there and put all build artifacts there.
Not renaming files avoids confusing editors etc.

if "/" in fragmentless
else (None, fragmentless)
)
return Link(path, file, fragment, title)
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually GitHub is decent at rendering asciidoc, they also support the cross references.
Though the dedicated site definitely looks nicer and is more discoverable.
Maybe we can add a link to it on the website.
It does have a large overlap with github so I'm not sure it will gain a lot of momentum.
But it's nice to have a replacement we can custommize as we add more docs

# Finally, generate the documentation,
# results will be saved to the output directory
# as specified in the `antora-playbook.yml`.
subprocess.run(["antora", "generate", "antora-playbook.yml"])
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to broken symlink, antora hangs indefinitely if there is a fifo in $PWD.
Also on a clean secondary worktree, it failed with

[23:39:47.976] FATAL (antora): Local content source must be a git repository: /home/johannes/git/kakoune2 (url: ./)

so it doesn't recognize that .git is a gitlink.
I'm not sure why it even interacts with Git.

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.

None yet

3 participants