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

WIP: Added first skeleton of a coding style for asciidoc #1530

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

Conversation

smoe
Copy link
Contributor

@smoe smoe commented Jan 24, 2022

First shot to address #1529

I did not want to separate it from the coding instructions since we regular code and documentation share weblate, some common features like tabs/indenting and the documentation is also a regular part of the source tree.
I forgot about @silopolis' very valid points on the integration of the glossary.

@smoe
Copy link
Contributor Author

smoe commented Jan 29, 2022

A pointer to the cheat-sheet on https://powerman.name/doc/asciidoc should be added.

Tables should likely get something alike [frame="topbot",grid="none"]

@smoe
Copy link
Contributor Author

smoe commented Jan 29, 2022

section title links are wanted? https://docs.asciidoctor.org/asciidoc/latest/sections/title-links/

autogenerated sectionids not to be consistent across languages? https://docs.asciidoctor.org/asciidoc/latest/sections/auto-ids/

Custom IDs should be above the section ID according to https://docs.asciidoctor.org/asciidoc/latest/sections/custom-ids/ (and it makes sence) - this I have messed up in my po4a-related changes.

@smoe
Copy link
Contributor Author

smoe commented Jan 29, 2022

The cross-references style should be decided.
https://docs.asciidoctor.org/asciidoc/latest/macros/xref-text-and-style/

My po4a changes ruined quite some image captions. I should instead have removed the alt text when this was identical to the caption and po4a was complaining. Anyway - the documentation style guide should explain about how much text it expects below an image. The captions today are basically just titles of an image, no description of what is seen in the image.
po4a could not handle the alt image descriptions.

Comment on lines 4 to 5
Documentation is written in asciidoc, which includes parts of the
UNIX man pages.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the "includes parts of of the UNIX man pages" !? Do you mean that parts of the documentation are in form of man pages ?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. For most of the small Hal components there is only documentation available as man page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

po4a could not handle the alt image descriptions

I have circumvented much of the "alt=" instances in the docs, but thinking about it and having read a bit more about it in the asciidoc documentation, this likely is more of a po4a bug.

languages. And executables implemented in any of these languages
may be called from anywhere, mostly from the scripting languages.

Every computer language is its very own syntax and customs to be structured,
Copy link
Contributor

Choose a reason for hiding this comment

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

s/is/has


In the declaration portion of a .comp file, begin each declaration at
the first column. Insert extra blank lines when they help group related
items.

In the code portion of a .comp file, follow normal C coding style.

== Code describing the functionality for the human
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add ", i.e. Documentation" at the end


In the declaration portion of a .comp file, begin each declaration at
the first column. Insert extra blank lines when they help group related
items.

In the code portion of a .comp file, follow normal C coding style.

== Code describing the functionality for the human

This is a very recent (1/2022) part of this document. Please help shaping it if you are familiar with asciidoc.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we stick to fixed line width, A CR should be inserted at the end of the first sentence.

Comment on lines 313 to 315
There are two basic documents, i.e. the
* Users' Guide and the
* Developers' Guide
Copy link
Contributor

Choose a reason for hiding this comment

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

What about Integrator's ?

Comment on lines 325 to 328
Every file should start with a header. This is typically
----
:lang: en
----
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't code blocks be surrounded by blanck lines ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's decide: Yes. :)

Comment on lines 329 to 332
and longer documents may also chose to set
----
:toc:
----
Copy link
Contributor

Choose a reason for hiding this comment

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

I personnaly find that any document benefits from being introduced by an outline of its structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, when these are on their own, yes. But our documents are typically included as part of another envelope document which provides an index. Some texts are so long that these should have a toc on their own, others maybe not.

Comment on lines 344 to 348
If a chapter/section header shall be granted the option to be
referenced from another part of the documentation then it needs an achor.
The anchor shall be a combination of an indicator of the kind
of block that is referenced (cha,sec,fig,tab,...) together with a
short name identifying the object.
Copy link
Contributor

@silopolis silopolis Jan 30, 2022

Choose a reason for hiding this comment

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

I'd be in favor of anchoring every chapter/section header, as well as every special/rich content blocks like tables, figures,...
Past these, subs of special interest should also be anchored.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With weblate activated, only the English texts will be edited. It may be preferable to only have anchors when they are indeed needed since this would possibly also incentivize a grep for other occurences when some extra info is added.

Comment on lines 350 to 352
* index entries for titles and other blocks

?
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be in favor of indexing every chapter/section header, as well as every special/rich content blocks like tables, figures,...
Past these, subs of special interest should also be indexed.
Using sub entries, a nicely structured extensive index could be built.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This refers to https://docs.asciidoctor.org/asciidoc/latest/sections/user-index/ and the (((names))) specified throughout the texts.
How do we deal with translations? Leave the English and have translations as secondary indices? Vice versa? Only the Translation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it does.
For the most part, I think we should have only translations. For specific and/or hardly translatable entries, a proper use of "see also".
Found https://web.archive.org/web/20180115025406/http://chimera.labs.oreilly.com:80/books/1234000001578/ch02.html#expand a good reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about it, we may not have an opportunity to decide about translations - weblate either picks it up or it doesn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right indeed... On second thought, it's more probably a po4a thing, Weblate only seeing what the first has decided to put in po files.

----

- reference

Copy link
Contributor

Choose a reason for hiding this comment

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

An entry about code blocks is also needed.

Found this https://blog.mrhaki.com/2019/12/awesome-asciidoctor-auto-number-callouts.html?m=1 very good for callouts in code blocks.

@smoe
Copy link
Contributor Author

smoe commented Jan 30, 2022

definitions::
   should use lists,
  • not
  • itemizations

@silopolis
Copy link
Contributor

silopolis commented Jan 30, 2022

About directories and files organization, as I find it perfectly clean and easy to understand, as well as I think Antora could/should be part of LinuxCNC future, I hope we can adopt the tree structure described here in the official documentation.
At the end of this page you can see how our different manuals could be organized in Antora modules in the future...

Edit: If you're not convinced, I invite you to have a look at the beautiful documentation source trees of https://docs.asciidoctor.org like the one for Asciidoc language and the master playbook

Edit2: For a quick intro to Antora https://github.com/owncloud/docs/blob/master/docs/what-is-antora.md

@smoe
Copy link
Contributor Author

smoe commented Jan 30, 2022

I like it.

@silopolis
Copy link
Contributor

Finally, for today ;), ownCloud documentation guidelines etc are a veeery interesting source of inspiration !
To the point that, if licence allows, we could consider deriving for these instead of starting from scratch...

https://github.com/owncloud/docs/tree/master/docs

@silopolis
Copy link
Contributor

Also we have this file https://github.com/LinuxCNC/linuxcnc/blob/master/docs/help/asciidoc-markup.adoc, which is actually in spanish that we should translate and merge or simply drop once we're done here.

@andypugh
Copy link
Collaborator

The conflict is just a heading level. Which I feel underqualified to fix.
Good to merge otherwise?

@smoe smoe changed the title Added first skeleton of a coding style for asciidoc WIP: Added first skeleton of a coding style for asciidoc Mar 30, 2022
@smoe
Copy link
Contributor Author

smoe commented Mar 30, 2022

I should sync with @silopolis a bit more before merging.

@silopolis
Copy link
Contributor

I think I create a feature branch locally for that, still have to push to GH.
As said in #linuxcnc-devel, should be able to get this merged in april

@petterreinholdtsen
Copy link
Collaborator

I discovered several .adoc files referred to other parts of the documentation three using direct links to linuxcnc.org. This make it harder to navigate the generated HTML text than necessary, and might lead the user into the wrong version of the document. The style guide should mention that internal links should use link:../path/to/sibling.html when pointing to sibling documents.

@hansu
Copy link
Member

hansu commented Jul 12, 2022

And also these links are not included in the link checking, right?

@petterreinholdtsen
Copy link
Collaborator

petterreinholdtsen commented Jul 12, 2022 via email

@hansu
Copy link
Member

hansu commented Jul 13, 2022

I believe they are.

Interesting.

Furthermore comes into my mind, that we should change the links to the current version instead of the general link where its not possible to use relative links like in man pages. So http://linuxcnc.org/docs/html/ should be changed to http://linuxcnc.org/docs/html/ so that the links still point to the correct version when there is a new release.

@petterreinholdtsen
Copy link
Collaborator

petterreinholdtsen commented Jul 13, 2022 via email

@hansu
Copy link
Member

hansu commented Jul 13, 2022

I believe we should do our best to avoid remote links like that completely instead.

I had these cases in mind where you refer to further documentation like the docs page from a man page.

@petterreinholdtsen
Copy link
Collaborator

@smoe Do you have time to brush up this proposal? We should try to get it into master to be able to point people to it. Perhaps the style guide content can be a topic for the next meeting?

@hansu
Copy link
Member

hansu commented Sep 24, 2022

I added the most important items for me that came into my mind.
@smoe can you please fill in the section about tables?

@silopolis
Copy link
Contributor

silopolis commented Sep 24, 2022 via email

@hansu
Copy link
Member

hansu commented Sep 24, 2022

The info about the usage of a generalized file like attributes.inc.adoc(like in #2062) should be added when the file is added.
And a link to the extended guide (#2062) should be added (or on the same level in the TOC?)

@hansu
Copy link
Member

hansu commented Sep 24, 2022

Any reason to contribute instead/without commenting #2062 ??

Not sure if we should have your "extended style guide" on the same level as this one or as a continuative link.

@silopolis
Copy link
Contributor

silopolis commented Sep 26, 2022 via email

@hansu
Copy link
Member

hansu commented Sep 26, 2022

How do you push commits to a branch that's not yours ? 🤔 How can I work on this too ?

Because I'm a maintainer and the author of this PR didn't prohibit it ;-)
image
You can work on this if Steffen adds you as a maintainer to his fork.

What I don't like here is that we again have one file for everything. I'd rather have one per language and have them gathered somehow in adequate ways for online and print, like a navigation menu and/or a parent document.

Maybe one for "real source code" and one for the formatting language(s). Otherwise the file for the Python style would be a very small one for example :D
But let's discuss that in a small video chat when I got rid of the cold.

@smoe
Copy link
Contributor Author

smoe commented Sep 27, 2022

You can work on this if Steffen adds you as a maintainer to his fork

Invitation sent.

@smoe
Copy link
Contributor Author

smoe commented Sep 27, 2022

Concerning the coding style document I am not as happy as I want to be. It was not fun to read. And I do not have any immediate idea how to change that.

Most parts are copied from somewhere else, from what I have understood. Rather than copying that, I think we should just have something like "we do it like they do, please read ... if this guide does not help you" and not copy from there.

What then remains are a set of questions we should decide for ourselves:

  • how do we write pin/functions/other LinuxCNC bits
  • how do we format tables
  • how do we spell various components of LinuxCNC
  • ...

What compromises are we doing today because asciidoc is limited compared with LaTeX

  • captions
  • references

So, executive summary, I hope to shorten this all - dramatically - and have only the LinuxCNC-relevant parts left.

Best,
Steffen

@hansu
Copy link
Member

hansu commented Sep 27, 2022

It was not fun to read.

:(

Most parts are copied from somewhere else, from what I have understood. Rather than copying that, I think we should just have something like "we do it like they do, please read ... if this guide does not help you" and not copy from there.

You mean like they did?: https://docs.zephyrproject.org/2.2.0/contribute/index.html#coding-style

What then remains are a set of questions we should decide for ourselves:

how do we write pin/functions/other LinuxCNC bits
how do we format tables
how do we spell various components of LinuxCNC
...

That we can take from #2062

@silopolis
Copy link
Contributor

silopolis commented Sep 27, 2022 via email

@smoe
Copy link
Contributor Author

smoe commented Sep 27, 2022

It was not fun to read.

:(

Sorry.

Most parts are copied from somewhere else, from what I have understood. Rather than copying that, I think we should just have something like "we do it like they do, please read ... if this guide does not help you" and not copy from there.

You mean like they did?: https://docs.zephyrproject.org/2.2.0/contribute/index.html#coding-style

That seems fine to me.

What then remains are a set of questions we should decide for ourselves:
how do we write pin/functions/other LinuxCNC bits
how do we format tables
how do we spell various components of LinuxCNC
...

That we can take from #2062

Should we integrate the glossary of weblate into what may serve as a reference for spelling?

@silopolis
Copy link
Contributor

silopolis commented Sep 27, 2022 via email

@silopolis
Copy link
Contributor

silopolis commented Sep 27, 2022 via email

@smoe
Copy link
Contributor Author

smoe commented Sep 27, 2022

The most important bit I think is that the project accepts those style guide rules as their own, and not as something that was imposed on them. Otherwise, following rules is not fun. That could likely be reached as

  1. reference to something that is nice and wideley spread and accepted
  2. refinements for what we like better
  3. LinuxCNC-specific abstractions of what is consistent and is frequently seen in today's documentation

and all should be as short as possible.

Concerning differences to LaTeX, I see

  • formatting of tables - I fail to get those pesky grid lines eliminated
  • references to tables and figures in the text that do no get the whole caption as a reference.
  • no support for multi-line captions.
  • literature references missing

@silopolis silopolis force-pushed the motivate_asciddoc_coding_style_instructions branch from e93bbbd to 58f38f3 Compare October 6, 2022 08:31
@silopolis
Copy link
Contributor

OK teammates, first two preliminary commits to put a little bit more structure here. I know some files are "light", but they'll expand.

Split out translation as it didn't fit in style guide and plan to pull relevent sections from docs/README to complete it.

I will now concentrate on the style-asciidoc.adoc trying to keep it as close to an special AsciiDoc ref guide as possible. I'll propose more content targeted at documentation management later...

@silopolis silopolis force-pushed the motivate_asciddoc_coding_style_instructions branch from 58f38f3 to 0786fc0 Compare October 6, 2022 08:43
@silopolis
Copy link
Contributor

silopolis commented Oct 11, 2022 via email

@smoe
Copy link
Contributor Author

smoe commented Oct 11, 2022

@silopolis - you have all permissions, I think/hope, but feel free to just take it and push it to some branch of yours. I have long forgotten this PR was out.

@silopolis
Copy link
Contributor

silopolis commented Oct 12, 2022 via email

@rene-dev
Copy link
Member

the Norwegian linuxcnc meeting approves this change.

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.

6 participants