question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Markdown headings support

See original GitHub issue

Support for markdown headings is listed as a goal in the README, but unsupported in https://github.com/microsoft/tsdoc/issues/169. In practice (using the tsdoc playground) it seems to be unsupported. In #169, it is also recommended to open a new issue for further discussion on this point if needed.

To start the discussion, I will share this example that currently works well with TypeDoc:

/**
 * Reverse an array in-place.
 *
 * @param array - The mutable array-like object of interest.
 *
 * @param start - The index of the first element in the range to be
 *   reversed, inclusive. The default value is `0`. Negative values
 *   are taken as an offset from the end of the array.
 *
 * @param stop - The index of the last element in the range to be
 *   reversed, inclusive. The default value is `-1`. Negative values
 *   are taken as an offset from the end of the array.
 *
 * #### Complexity
 * Linear.
 *
 * #### Undefined Behavior
 * A `start` or  `stop` index which is non-integral.
 *
 * #### Example
 * ```typescript
 * import { ArrayExt } from '@lumino/algorithm';
 *
 * let data = [0, 1, 2, 3, 4];
 * ArrayExt.reverse(data, 1, 3);  // [0, 3, 2, 1, 4]
 * ArrayExt.reverse(data, 3);     // [0, 3, 2, 4, 1]
 * ArrayExt.reverse(data);        // [1, 4, 2, 3, 0]
 * ```
 */

In this comment, the #### Example heading can and should be replaced with @example. It is not so clear what to do with the #### Complexity and #### Undefined Behavior headings. A logical first step is to put both in a @remarks section, but it is unclear if there is any way to subdivide the remarks section further (without falling back to HTML), other than to allow markdown headers.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
octogonzcommented, Aug 20, 2020

If there is no nesting, should tsdoc really try to enforce/warn about which levels are used? Can it just not pass through the headers that are given?

There are different scenarios for different tools. The setup that I’m used to is like this:

  1. A developer writes a code comment using VS Code – an ESLint rule will underline issues caught by the TSDoc plugin
  2. The developer makes a PR – API Extractor will report analysis errors caught during the CI build.
  3. Some time after the PR is merged, the API documentation website will get regenerated (e.g. when a release is published) – at this step API Documenter can report errors relating to documentation.

Typically the original developer may never see the final rendered output at all. Even if there is a nice staging server stood up somewhere, the person writing the code may not be interested in that, and would not bother to look at it.

Thus wherever reasonable, it is desirable to catch mistakes as early in the pipeline as possible. Making TSDoc very strict and predictable enables us to catch issues by looking at code comments, without needing to run an entire documentation pipeline to understand how it will get rendered. For people who don’t have this requirement, these strict checks can easily be disabled.

1reaction
octogonzcommented, Aug 18, 2020

Let’s start with 2 not 1, since the first line of docs is the headline 1 and in HTML only one h1 is suggested/allowed. One # would be marked as wrong then.

* https://www.w3.org/wiki/HTML/Usage/Headings/h1only

* https://www.w3.org/QA/Tips/Use_h1_for_Title

I did not know that! Maybe TSDoc should start with ## then, since the title is expected to be provided by the documentation system.

Does anybody else have an issue with this? We could even issue a validation warning for # (or ### without ##).

CC @rbuckton

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basic Syntax - Markdown Guide
Markdown applications don't agree on how to handle a missing space between the number signs ( # ) and the heading name. For...
Read more >
Markdown Syntax Documentation - Daring Fireball
Markdown supports two styles of headers, Setext and atx. Setext-style headers are “underlined” using equal signs (for first-level headers) and dashes (for ...
Read more >
Basic writing and formatting syntax - GitHub Docs
Headings. Styling text. Quoting text. Quoting code. Supported color models ... Ignoring Markdown formatting. Disabling Markdown rendering. Further reading.
Read more >
Markdown Guide - Things Support - Cultured Code
Things supports Markdown for formatting text in your notes. It allows you to add style and structure by typing a few special punctuation...
Read more >
Markdown Quick Reference Cheat Sheet - WordPress.com
Note: The instructions from this guide are referring to the Classic Editor. If you are using the WordPress block editor, please see this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found