- Guidelines for describing workflows
- Markdown vs Google Docs
- Style and cosmetic lints
- Google docs style conventions
- Convert between Gdocs and Markdown
- Make no assumptions on the user's knowledge
- Nothing is obvious to somebody who doesn't know
- Add ways to verify if a described process worked
- E.g., "do this and that, if this and that is correct should see this"
- Have a trouble-shooting procedure
- One approach is to always start from scratch
- We prefer to use Markdown for technical documentation
- We use Google for notes from meetings and research
- Can use vim
- Can version control
- Easy to use verbatim (e.g., typing
foobar
) - Easy to style using pandoc
- Easy to embed code
- Easy to add Latex equations
- Easy to grep
- Easy to embed figures
- Easy to collaborate
- Easy to make quick changes (instead of making a commit)
- Easy to publish (just make them public with proper permissions)
- Styling
- Interesting add-ons:
- Enable Markdown
- Code blocks
- Use darcula, size 10
def hello(): print("hello")
- Use darcula, size 10
- Auto-latex equations
- Use Markdown
- If doc is going to be used as a public guideline
- If doc has mostly text, code, and formulas
- If there are notes from a book
- Use Gdoc
- If doc requires a lot of images that cannot be placed as text
- If doc is a research of an analysis
- Markdown cheatsheet
- Google guide to Markdown
- TODO(gp): Make sure it's compatible with our linter
- Most cosmetic lints described further can be taken care automatically by our markdown linter, so make sure to run it after implementing the changes
- The file is
dev_scripts/lint_md.sh
, see the docstrings for more details- Example run:
dev_scripts/lint_md.sh docs/Documentation_about_guidelines.md
- Example run:
- Do not mix manual edits and linter runs. Best practice is to run the linter and commit the changes it made as separate commit
- If the linter messes up the text, file an issue with examples of what the linter does incorrectly
- Unfortunately both markdown and GitHub don't support automatically generating a TOC for a document
- To generate a table of content:
- Add the following tag at the top of the markdown file below the document
title:
<!-- toc -->
- Run the markdown linter in order to build TOC automatically
- Add the following tag at the top of the markdown file below the document
title:
- Vim has a
:gq
command to reflow the comments - There are plugins to take care of this for PyCharm
- Our markdown linter takes care of reflowing the comments as well
-
Leave an empty line after a heading to make it more visible
-
Bad
# Coming through! I've big important things to do! - ... and his big important wheels got STUCK!
-
Good
# Very important title - Less important text
-
- We like using bullet list since one can represent thought process more
clearly, e.g.,
- This is thought #1
- This is related to thought #1
- This is thought #2
- Well, that was cool!
- But this is even better
- This is thought #1
- We strictly use
-
instead of*
, circles, etc.:- Bad
* Foo bar! * hello * world * Baz
- Good
- Foo bar! - hello - world - Baz
- Bad
- We use
code
style for- Code
- Dirs (e.g.,
/home/users
) - Command lines (e.g.,
git push
)
- When using a block of code use the write syntax highlighting
- Bash
> git push
- Python
if __name__ == "__main__": predict_the_future() print("done!")
- Bash
- GitHub / pandoc seems to render incorrectly a code block unless it's indented
over the previous line
- Bad
> git push
- Good
> git push
- Avoid to use screenshots whenever possible!
- However, sometimes we need it (e.g., plot infographics, website inteface, etc.)
- To do it correctly:
- Place your screenshot in any comment window at GitHub
- Make sure your link has no not-English symbols in
alt
section - Place the generated and edited link to the markdown file
- Use English spell-checker
- Unfortunately this is not enough
- Type somewhere where you can use several free choices:
- Grammarly
- LanguageTool
- Or other proofreading and copy-paste
- This is super-useful to improve your English since you see the error and the
correction
- Otherwise you will keep making the same mistakes forever
- You can:
- Check in a branch and use GitHub to render it
- Use Pycharm to edit, which also renders it side-by-side
- Compare your markdown with already published documentation
- We add N (where N is the heading level)
#
before the heading name, e.g.,- Heading 1:
# Heading 1
- Heading 2:
## Heading 2
- Heading 1:
- The reason is that sometimes one doesn't have the time or the patience to format things properly, so at least there is some indication of the level of the titles
- Avoid having multiple
#
separatd by a space that sometimes appear in a process of convertion of Gdocs to Markdown files- Bad
# # Heading 1
- Good
# Heading 1
- Bad
- Normal text:
- Font: Arial
- Font size: 11
- Headings:
- Font: Arial
- Style: bold
- Font size: should be adjusted automatically when one converts “Normal text” to “Heading N”, e.g., when converting some text of size 11 to “Heading 1” the font sizes becomes 20
-
In general, we recommend using this approach
-
This python script converts Docx to Markdown using Pandoc.
-
Pros
- Removing artifacts with this python script, less manual work
- Best for a large document
- Handle figures
-
Cons
- Need to move files
- Download Google document as docx
- Convert it to markdown using
convert_docx_to_markdown.py
- Usage:
> ../dev_scripts/convert_docx_to_markdown.py --docx_file Tools_Docker.docx --md_file Tools_Docker.md
- This command should be run directly under the target output directory for the Markdown file, in order to generate correct image links. Otherwise, you'll need to manually fix the image links.
- File names can't contain any spaces. Therefore, use underscores
_
to replace any spaces.
-
Fix some formatting manually before running the Markdown linter.
- Read through Style and cosmetic lints for
Markdown formatting and fix some formatting based on the rules.
- Summary
- Add the following tag at the top of the markdown file below the document
title:
<!-- toc -->
- Use bullet lists to organize the whole Markdown for consistency with other docs. See Coding_Style_Guide.md or any other published Markdown format as reference
- Add missing ``` around code blocks. These could be missing in the original Google doc. Also adjust code block indentations if needed
- Add the following tag at the top of the markdown file below the document
title:
- Summary
- Read through Style and cosmetic lints for
Markdown formatting and fix some formatting based on the rules.
-
Remove empty lines manually
:'<,'>! perl -ne 'print if /\S/'
-
Run the
lint_md.sh
- Usage:
> dev_scripts/lint_md.sh docs/Documentation_about_guidelines.md
- What the linter will do:
- Build TOC automatically
- Adjust the indentation to improve the Markdown's format (but the precondition is that you have properly adjusted the indentation levels).
- Remove extra empty lines under headings
- Adjust text layout
- Do not mix manual edits and linter runs
- If the linter messes up the text
- File bugs in
amp
with examples what the linter does incorrectly
- File bugs in
- Usage:
-
Last steps
- Compare the generated markdown file with the original Gdoc from top to bottom to ensure accurate rendering.
- Review the markdown file on GitHub to make sure it looks good, as it may slightly differ from the preview in your local markdown editor
-
When a gdoc becomes obsolete or it's deleted
- Add a note at the top of a gdoc explaining what happened
- Example: "Moved to /new_markdown_file.md"
- Strike out the entire document
- Move the gdoc to the _OLD directory
-
Best for a large document
-
Approach 1 - Chrome Docs to Markdown extension:
- Use the Docs to Markdown
extension
- Install the extension from the G Suite marketplace
- User guide for the extension
- One needs to accept/reject all suggestions in a gdoc as the extension works poorly when a document is edited in the suggestion mode
- Use the Docs to Markdown
extension
-
Approach 2 - Online converter:
-
Also need to go through Cleaning up converted markdown
-
You might need to remove artifacts manually
- Approach 1:
- Run
> pandoc MyFile.md -f markdown -t odt -s -o MyFile.odt
- Download the template in odt format
- Run
> pandoc code_organization.md -f markdown -t odt -s -o code_org.odt --reference-doc /Users/saggese/Downloads/Gdoc\ -\ Template.odt
- Open it with TextEdit, copy-paste to Gdoc
- Run
- Approach 2:
- Instead of copy-paste the markdown into Gdocs, you can copy the rendered
markdown in a Gdoc
- Gdocs does a good job of maintaining the formatting, levels of the headers, the links, and so on
- Instead of copy-paste the markdown into Gdocs, you can copy the rendered
markdown in a Gdoc
- Approach 3:
- https://markdownlivepreview.com/
- TODO(gp): Check if the roundtrip works