diff --git a/docs/css.md b/docs/css.md new file mode 100644 index 0000000..81104cf --- /dev/null +++ b/docs/css.md @@ -0,0 +1,14 @@ +# CSS + +CSS, or [Cascading Style Sheets](https://en.wikipedia.org/wiki/CSS), define the presentation layer of a website. Our aim at Dyalog is that as a documentation contributor, you should not need to get your hands dirty at this level. Moreover, any CSS changes need to be discussed as a wider group, as there are more aspects (beyond MkDocs) to the documentation build pipeline that rely on the CSS, like the CHM and PDF versions of the documentation. CSS that you write is not automatically picked up (paged media CSS is very different). + +## Dyalog MkDocs CSS + +The CSS defining the Dyalog-specific customisations are found in the locations specified in the `mkdocs.yml` file. Typically, that means `docs/style`. In there, you'll see two files of interest: + +1. **main.css** +2. **extra.css** + +These are not mandated by MkDocs, but any CSS files found in the directories specified in the `mkdocs.yml` file will be included. Note, however, that there is a lot more CSS injected as part of the rendering pipeline, specific to the [MkDocs Material](https://github.com/squidfunk/mkdocs-material) theme, defining things like navigation panels etc. There _are_ ways to hook into that, but this is not something we should encourage. + +As a "run of the mill" documentation contributor, you should rarely need to consider the CSS. \ No newline at end of file diff --git a/docs/images.md b/docs/images.md new file mode 100644 index 0000000..1a1deef --- /dev/null +++ b/docs/images.md @@ -0,0 +1,32 @@ +# Figures with Captions + +!!! Info "Information" + We use the [caption](https://github.com/tobiasah/mkdocs-caption#readme) plugin to automatically number and cross-reference figures and tables in Material for MkDocs. + +The Markdown way to add an image is a Markdown link preceded by an exclamation mark: + +```other + +``` + +By using the [attribute list](https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/#attribute-lists) syntax we can add CSS classes, id, attributes etc, without resorting to HTML. + +```other +{ width=300px #MyImgId } +``` + +Here is an example: + +```other +{ width=300px #MyElephant} +``` + +{ width=300px #MyElephant} + +Like with [tables](tables.md), we reference the image by its id by an "empty" link: + +``` +The beautiful specimen in [](#MyElephant) is a bull with the name of Kevin. +``` + +The beautiful specimen in [](#MyElephant) is a bull with the name of Kevin. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index d6b632d..20a708c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,7 +3,6 @@ ## To Do - references in HTML vs. PDF - consider linking to specific document versions in references to other documents -- what is happening with [figures with captions](./style.md#figures-with-captions) (and tables) ## Markdown and HTML This document, and the documentation to which it refers, is written in Markdown. @@ -27,3 +26,13 @@ For more examples of markdown and equivalent HTML, see the [basic syntax page on Not only does Markdown render to HTML so that it can be viewed on any web browser, but you can also use HTML inside Markdown documents in order to apply custom styling with CSS or to create layouts which aren't possible with just Markdown. In general, it is best to try and stick to just Markdown where possible because maintaining a set of custom CSS classes and styles can be cumbersome. Sometimes it is convenient to [include markdown inside HTML tags](./style.md#markdown-inside-html). + +## Resources + +* [MkDocs](https://www.mkdocs.org/) +* [MkDocs Material](https://squidfunk.github.io/mkdocs-material/) theme +* [Markdown extensions](https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/) available in Material +* [Attribute lists](https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/?h=attribute+lists#attribute-lists) +* [GitHub Flavored Markdown Spec](https://github.github.com/gfm/) +* [Extended Markdown tables](https://github.com/fumbles/tables_extended) +* [Captions](https://github.com/tobiasah/mkdocs-caption#readme) diff --git a/docs/style.md b/docs/style.md index a9bd607..af37111 100644 --- a/docs/style.md +++ b/docs/style.md @@ -4,7 +4,7 @@ When using [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) ## Document Structure and General Style Guidelines !!! Info "Information" - [Style_Guide_and_Best_Practice](http://wiki.dyalog.bramley/index.php/Style_Guide_and_Best_Practice) on the internal wiki covers: + [Style_Guide_and_Best_Practice](https://wiki.bramley.dyalog.com/index.php/Style_Guide_and_Best_Practice) on the internal wiki covers: - The structure to use for documents - General rules to follow when writing, including language-related guidelines such as the use of Dyalog-specific terms, how to mention third-party products, and the use of abbreviations and acronyms. @@ -17,19 +17,33 @@ Some aspects have been adapted in this document for use with Material for MkDocs - [Code](#code) - [Notes](#notes) +## Document structure + +In a MkDocs site, the left panel is defined by the organisation of the documentation source files and directories. Strive to keep this simple, and aim for fewer, larger files, instead of many smaller ones. The right panel is defined by each document's internal semantic structure (its headings sequence). We want a balance between the left and right navigation panels for several reasons: + +1. Fewer HTTP requests means a decrease in perceived latency. +2. The MkDocs Material theme is designed with the two-panel navigation in mind. This means that if you write many, small documents with no internal sections, the presentation lools weird with large areas of whitespace. +3. Especially for large sites, a large, multi-tiered left side is harder to operate, as opening large folded sections soon becomes confusing. + +Aim for a flatish structure, grouping logically related aspects into single Markdown documents. + ## Headings -Headings are denoted by a number of octothorpes corresponding to the heading level. +Headings are denoted by a number of octothorpes (hashes) corresponding to the heading level. ``` -# Heading 1 -## Heading 2 -###### Heading 6 +# Heading 1 (H1) +## Heading 2 (H2) +###### Heading 6 (H6) ``` Headings should be written in [title case](https://en.wikipedia.org/wiki/Title_case#Chicago_Manual_of_Style). Try to avoid multiple consecutive headings with no intervening text. +Crucially, every document *must* start with an H1, and the heading sequence should never have gaps: when increasing nesting depth, an H{X} should only be followed by H{X+1}. Headings describe the semantic (the "meaning") structure of the document, not the layout. MkDocs rely on the semantic structure to lay out its left, and right navigational panels. + +Additionally, the MkDocs source may be used to render the documentation in different formats, such as CHM and PDF, and these conversions may depend on the correct semantic documentation structure. + ## Italics Use italics when: @@ -39,15 +53,12 @@ Use italics when: Italics are denoted by single asterisks surrounding the text. -
example
- -``` +``` { .example} The word *asterisks* is italicised. ``` -example
- -``` +``` { .example } Go to the **file** menu ``` -Example: link text is URL
+- Example: link text is URL + ``` + Link can be downloaded from [https://github.com/Dyalog/link](https://github.com/Dyalog/link) + ``` + Link can be downloaded from [https://github.com/Dyalog/link](https://github.com/Dyalog/link) -``` -Link can be downloaded from [https://github.com/Dyalog/link](https://github.com/Dyalog/link) -``` +- Example: alternative link text + ``` + Download [Link](https://github.com/Dyalog/link) and... + ``` + Download [Link](https://github.com/Dyalog/link) and... -Example: alternative link text
+All HTML is valid Markdown, which on occasion provides a helpful escape hatch to create more elaborate constructs not supported directly in Markdown. However, avoid this unless absolutely necessary. The justifications for this are: -``` -Download [Link](https://github.com/Dyalog/link) and... -``` +1. It's rarely required, and usually a sign that what you're doing can be simplified. +2. It represents a contribution barrier. Markdown is designed to be read and written by humans first; HTML is not. -Markdown renders in here. For example, *italicised text*.
-> + ## Notes @@ -134,9 +146,7 @@ Notes are used to highlight important information. Hints, tips, best practice and recommendations from Dyalog Ltd -example
- - ``` + ``` { .example} !!! Tip "Hints and Recommendations" If both DOSLimit and BufferSize are set, then the smaller value applies. Dyalog Ltd recommends using a modest BufferSize and not setting EnableBufferSizeHttp to ensure that abnormally large headers are not processed, then setting an appropriate DOSLimit to accommodate the expected size messages. ``` @@ -311,23 +321,35 @@ Instructions are written as an ordered list. Blocks that contain instructions sh ## Examples Examples are used to demonstrate the functionality discussed. -Introduce full examples with `Example
` (or "Examples") so that it is on a line by itself. +Introduce full examples with: + +``` +example (or examples) +{ .example} +``` + +which renders as `example
`. Exception – if there are several consecutive examples illustrating different things, they can each be introduced with "Example:example
+!!! Info "Information" + The examples in this document use `example
+example +{ .example} + This is an example ```example
+example +{ .example} + This is an example -+⌿÷≢
) is the sum
>
#### APL Code blocks
-Code blocks use `
` or triple backticks with "apl" (lowercase) to denote the language.
+Code blocks use triple backticks with "apl" (lowercase) to denote the language.
-Example: Using HTML
- -``` - 3+⍳10
-4 5 6 7 8 9 10 11 12 13
-
-```
```apl
3+⍳10
@@ -392,30 +407,18 @@ Code blocks use `
` or triple backti
```
#### Non-APL Code Blocks
-Use `[your code here]
` or triple backticks with "other" (lowercase).
-
-Example: Using HTML
- -``` ->>> print("hello") # Code block example
-hello
-```
-
-```other
->>> print("hello") # Code block example
-hello
-```
+Use triple backticks with the name of the language or format, or "other" (lowercase).
Example: Using backticks
`````` -```other +```python >>> print("hello") # Code block example hello ``` `````` -```other +```pythom >>> print("hello") # Code block example hello ``` @@ -465,39 +468,28 @@ When referring to keyboard shortcuts, such as those controlled by `⎕KL` on Mic Closing angle brackets must be escaped with a backslash (e.g. `Example
+Example +{ .example} ```Example
+example +{ .example} ``` Press the Enter key. ``` -Example
``` -Use :material-apple-keyboard-command: + C to copy text +Use :material-apple-keyboard-command: + C to copy text ```+Table: Cells with content { #MyTable } + +| heading 1 | heading 2 | +| --------- | --------- | +| content 1 | content 2 | +| content 3 | content 4 | ++ +which should render as: + +Table: Cells with content { #MyTable } + +| heading 1 | heading 2 | +| --------- | --------- | +| content 1 | content 2 | +| content 3 | content 4 | + +You, the author, are responsible for choosing a unique table id (the `#MyTable` in this case) which is unique and appropriate for the table. + +To reference a table based on its id, insert a Markdown link to the id, with an empty anchor: + +
+As shown in [](#MyTable), yadda yadda. ++ +where the anchor text should be filled in by the extension: + +As shown in [](#MyTable), yadda yadda. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index e099ba2..96cb33d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -5,6 +5,13 @@ theme: favicon: 'img/favicon-32.png' language: en logo: 'img/dyalog-white.svg' +plugins: + - caption: + table: + enable: true + start_index: 1 + increment_index: 1 + position: bottom markdown_extensions: - admonition - pymdownx.highlight: @@ -16,6 +23,9 @@ markdown_extensions: - pymdownx.emoji: emoji_index: !!python/name:materialx.emoji.twemoji emoji_generator: !!python/name:materialx.emoji.to_svg + - markdown_tables_extended + - toc: + title: On this page extra_css: - styles/custom-admonitions.css - styles/main.css @@ -23,4 +33,7 @@ nav: - Home: index.md - Rules for Writing Documentation: rules.md - Style Guide: style.md + - Images: images.md + - Tables: tables.md + - CSS: css.md - Process: process.md \ No newline at end of file