Skip to content
Snippets Groups Projects

Draft: Convert coding guidelines to markdown

Open Frank Winklmeier requested to merge cppguidelines into main

Experimental migration of the C++ coding guidelines (by @ssnyder) from the original org-format [1] to markdown. Mostly done using pandoc and few extra fixes using sed (see full command below).

Comparison:

TODO (in case we decide to make this our primary source for the coding guidelines)

  • Author attribution
  • Change a few code blocks to verbatim text
  • Cleanup footnotes
  • Fix and add a few missing anchors (already missing in org-format)
  • Fix spellchecker
  • Use a better name/URL so we could distinguish this from some future Python coding guidelines

[1] https://gitlab.cern.ch/ssnyder/coding-rules/-/blob/master/rules.org

To reproduce
cat rules.org |
    # Convert example code blocks to proper C++ code blocks
    sed 's/BEGIN_EXAMPLE/BEGIN_SRC cpp/' | sed 's/END_EXAMPLE/END_SRC/' |
    # Convert to markdown
    pandoc --shift-heading-level-by=1 --from=org --to=markdown_strict+backtick_code_blocks+footnotes |
    # Fix double quotes
    sed 's/\\`\\`/"/g' | sed "s/''/\"/g" |
    # Create proper anchors
    sed 's/\\\[<span id="\(.*\)"><\/span>\\\]/[[\1]](#\1){: #\1}/' > rules.md
Edited by Frank Winklmeier

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Frank Winklmeier added 5 commits

    added 5 commits

    Compare with previous version

  • Frank Winklmeier changed the description

    changed the description

    • hi Frank -

      Thanks. I'd been meaning to play around with this a bit. It'll be a little while before i can look at this in detail, but a few quick comments.

      Did you try converting from the md to pdf? One of the reasons that i originally set the document up like this was so as to be able to get a good-quality pdf version.

      Comparing the outputs, they both have better points and worse points. If i were looking at it frequently, though, i think i'd prefer the original version. Having the sections numbered makes it easier to navigate, and for long texts, i generally find a serif font easier to read,. But those are presumably functions of the style, not of the input.

      I am unsure that "generic" markdown is really appropriate for a "complex" document. I hope, for example, that one doesn't need to number citations by hand, as in the example here. And not having a comment syntax seems mind-boggling. (HTML comments seem to work with some translators but not others...) Maybe pandoc-markdown would be better...

    • Author Maintainer

      Thanks for the feedback. I agree, one should decide carefully which format we want to use as the primary source for this type of document (admittedly, org-mode is maybe a bit exotic for most people). Just a few comments:

      • Style (font, etc.) can certainly be adjusted. Automatic header numbering (in the HTML) would be a matter of adding some CSS.
      • The footnotes are automatically numbered. But the pandoc export somehow decided to convert them to hard-coded numbers instead of using your original named footnotes.
      • I added a pandoc-generated PDF version to the top of the page for comparison. Although even the browser-builtin "Print..." produced something reasonable.

      One of the most problematic features to convert across formats are the local anchors to individual guidelines, which I consider a must-have (very useful for MR reviews). On the current HTML pages, they are defined, but don't appear as actual links either.

      In any case, I would really leave it up to you to decide on the source format as you are the one maintaining the coding guidelines and then we'll see how to best integrate them into atlas-software.docs (the current iframe solution is really not very ergonomic).

    • Author Maintainer

      I made a bit more progress on this draft and fixed the remaining issues. The only remaining problem I found was that Markdown does not automatically number the footnotes according to occurrence in the text. So one has to manually put them in the correct order (I changed them back to the same name as in the original org source).

      Of course, many of them could just be converted to normal hyperlinks instead of footnotes.

    • Please register or sign in to reply
  • added 1 commit

    • a4e62939 - Add PDF export of coding guidelines

    Compare with previous version

  • added 1 commit

    • b53605f5 - Add PDF export of coding guidelines

    Compare with previous version

  • added 1 commit

    • 46bd62e3 - Add PDF export of coding guidelines

    Compare with previous version

  • added 1 commit

    • 6a44c1f9 - Add PDF export of coding guidelines

    Compare with previous version

  • added 1 commit

    • a2ea0fd9 - Add PDF export of coding guidelines

    Compare with previous version

  • Frank Winklmeier added 100 commits

    added 100 commits

    Compare with previous version

  • Frank Winklmeier added 2 commits

    added 2 commits

    • 1efd4a5e - Fix footnotes in coding guidelines
    • 09b5bb2a - Add section numbering

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • Frank Winklmeier marked the checklist item Cleanup footnotes as completed

    marked the checklist item Cleanup footnotes as completed

  • Frank Winklmeier added 8 commits

    added 8 commits

    • cecdc61d - Fix footnotes in coding guidelines
    • 37316694 - Add section numbering
    • fc203f79 - Make changelog a pure list and change some code blocks to text
    • 651fa603 - Fix and add some missing anchors
    • 59b2387b - Make spellchecker pass on coding guidelines
    • 46d7b956 - Ignore footnotes in spellchecker
    • 6c184f36 - Fix broken link to CERN-UCO/1999/207
    • f714d991 - Add original authors

    Compare with previous version

  • Frank Winklmeier marked the checklist item Author attribution as completed

    marked the checklist item Author attribution as completed

  • Frank Winklmeier marked the checklist item Change a few code blocks to verbatim text as completed

    marked the checklist item Change a few code blocks to verbatim text as completed

  • Frank Winklmeier marked the checklist item Fix and add a few missing anchors (already missing in org-format) as completed

    marked the checklist item Fix and add a few missing anchors (already missing in org-format) as completed

  • Frank Winklmeier added 4 commits

    added 4 commits

    • 1724d4ea - Make spellchecker pass on coding guidelines
    • a56401f0 - Ignore footnotes in spellchecker
    • 91eba5c5 - Fix broken link to CERN-UCO/1999/207
    • a5d9ba65 - Add original authors

    Compare with previous version

  • Frank Winklmeier marked the checklist item Fix spellchecker as completed

    marked the checklist item Fix spellchecker as completed

  • Frank Winklmeier added 14 commits

    added 14 commits

    • a5d9ba65...da3d1f7a - 4 commits from branch main
    • 1fcd8666 - Convert coding guidelines to markdown
    • 06fa7ee9 - Add PDF export of coding guidelines
    • 0b39e1ad - Fix footnotes in coding guidelines
    • 67bca0fb - Add section numbering
    • c56f717f - Make changelog a pure list and change some code blocks to text
    • d4f03c05 - Fix and add some missing anchors
    • 577190cb - Make spellchecker pass on coding guidelines
    • 21a69cbe - Ignore footnotes in spellchecker
    • aafc1bb9 - Fix broken link to CERN-UCO/1999/207
    • bd8e7b12 - Add original authors

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading