typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
689 stars 172 forks source link

enhance examples in a type declaration block #571

Closed FranckFreiburger closed 5 months ago

FranckFreiburger commented 5 months ago

Hello, I'm using some examples in the type declaration and I'm wondering if it's possible to make them nicer.

image

The related block is:


/**
 * [[get]]() and [[set]]() functions of this object are called when the lib needs to save or load already compiled code. get and set functions must return a `Promise` (or can be `async`).
 * Since compilation consume a lot of CPU, is is always a good idea to provide this object.
 *
 * **example:**
 *
 * In the following example, we cache the compiled code in the browser's local storage. Note that local storage is a limited place (usually 5MB).
 * Here we handle space limitation in a very basic way.
 * Maybe (not tested), the following libraries may help you to gain more space [pako](https://github.com/nodeca/pako), [lz-string](https://github.com/pieroxy/lz-string/)
 * ```javascript
 *  ...
 *  compiledCache: {
 *      set(key, str) {
 *  
 *          // naive storage space management
 *          for (;;) {
 *  
 *              try {
 *  
 *                  // doc: https://developer.mozilla.org/en-US/docs/Web/API/Storage
 *                  window.localStorage.setItem(key, str);
 *                  break;
 *              } catch(ex) {
 *                  // here we handle DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'XXX' exceeded the quota
 *  
 *                  window.localStorage.removeItem(window.localStorage.key(0));
 *              }
 *          }
 *      },
 *      get(key) {
 *  
 *          return window.localStorage.getItem(key);
 *      },
 *  },
 *  ...
 * ```
 */
    compiledCache?: Cache,
tgreyuk commented 5 months ago

The problem is code blocks are not going to work in a table view. You could try the list view. It looks like you are on v3, in which case you can try objectLiteralTypeDeclarationStyle=list. The only way to get the code block rendering in a table is to convert it to html which is not currently possible.

FranckFreiburger commented 5 months ago

thanks for the tip, the result is better.