typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

Folder of markdown doc

Open movrack opened this issue 8 years ago • 20 comments

Is it possible to include a folder of documents writted in markdown ? A bit like githubs wiki to be able to write more files than only one readme big file.

movrack avatar Jun 30 '16 09:06 movrack

Does #63 help at all?

aciccarello avatar Jun 30 '16 12:06 aciccarello

It look to be a solution but I can't make it work. I am on v 0.4.4. I use this command line:

    typedoc -- --options typedoc.json --exclude '**/*.spec.ts' --exclude 'node_modules/**/*' --includes 'docs2/' ./app/

and docs2 contains 2 files - demo1.md - demo2.md

typedoc.json is:

{
  "name": "Mobile app",
  "mode": "modules",
  "out": "docs/",
  "theme": "default",
  "ignoreCompilerErrors": "true",
  "includeDeclarations": false,
  "experimentalDecorators": "true",
  "emitDecoratorMetadata": "true",
  "target": "ES5",
  "moduleResolution": "node",
  "preserveConstEnums": "true",
  "stripInternal": "true",
  "suppressExcessPropertyErrors": "true",
  "suppressImplicitAnyIndexErrors": "true",
  "module": "commonjs"
}

But I can't found demo1 or demo2 on generated doc in docs folder.

Moreover (it's an other error but probably a mess of my config), and because i am writting here all the conf, I always see theses "errors", that i want to exclude: Error: /Users/.../node_modules/ionic-native/dist/plugins/webintent.d.ts(22) Cannot find name 'Promise'. Error: /Users/.../node_modules/rxjs/Observable.d.ts(9) Cannot find name 'Promise'.

movrack avatar Jul 01 '16 07:07 movrack

The doc states:

--includes <path/to/includes>
Specifies the location to look for included documents. One may use [[include:FILENAME]] in comments to include documents from this location.

So: do you refer to demo{1|2}.md somewhere in a tsdoc comment in one of your source files? e.g.

/**
 * [[include:demo1.md]]
 */

I did not use the feature myself, but that is what I would expect to work. This should then lead to demo1.md being searched and included into documentation. But maybe that is not even what you originally wanted? I understood it as if you wanted to integrate a complete doc structure, which - if I guess correctly - you want to be inserted e.g. in the navigation, so that you have typedoc and your documentation accessible in one place?

0815fox avatar Jul 01 '16 09:07 0815fox

It's working, I can see the included content on the readme but it's I was expecting. Here, if i includes all files, I will see all content on a big big big file to scroll on the first page. I was more thinking about something like a link in on the website generated who can open the directory included. (for example in top right). And who can show md files.

And thee readme is also shown on the git repository first page but the [[include:demo1.md]] will not be shown on it.

movrack avatar Jul 01 '16 09:07 movrack

Guys were you able to make the includes work?

I try it like this with no success

here is how I run typedoc

"typedoc --out ./doc/ ./src --externalPattern '**/node_modules/**' --ignoreCompilerErrors --includes 'mdDocs/'"

in my mdDocs I have TypeScriptReactReduxTutorial.md so in my code file I do

// ./src/store/index.ts

/**
 * [[include:TypeScriptReactReduxTutorial.md]]
 */

import { combineReducers } from 'redux'

import { counterReducer } from './counter/reducer'

import { IApplicationState } from './types'

/**
 *  Whenever an action is dispatched, Redux will update each top-level application state property
 * using the reducer with the matching name. It's important that the names match exactly, and that
 * the reducer acts on the corresponding IApplicationState property type.
 */
export const rootReducer = combineReducers<IApplicationState>({
  counter: counterReducer
})

But nothing from my md file is being show in the generated docs only a line like this is being added

Defined in store/rootReducer.ts:18

hayk94 avatar Aug 07 '18 08:08 hayk94

Including a MarkDown file by referencing it inside of my API documentation works for me. However, I think the original intent of this issue (and what I'm looking for as well) is to have a folder of MarkDown files that can be listed in the table of contents without being explicitly part of the API.

For example, if you wish to make the output of TypeDoc your complete documentation solution, you may want to include a page for architecture design, acknowledgements, etc. That information could go in the README, but for many projects it would be nice to split up into separate pages.

cuibonobo avatar Sep 09 '18 15:09 cuibonobo

Any update on this? Will TypeDoc ever support a folder of Markdown docs together with the code generation?

reyalpsirc avatar Feb 14 '19 16:02 reyalpsirc

A very hacky solution: Make a .ts file with an empty module and put your markdown in the comments for that module. Note that block comments in your markdown need to be converted to groups of single line comments.

/**
 * ## My Long Markdown File
 * Put your markdown here!
 * ```js 
 * //my
 * //block
 * //comment
 * ``` 
*/
namespace My_Guide {}

Credit goes to jaykaron for the find

nadavhames avatar Apr 04 '19 21:04 nadavhames

Heres a quick script that converts Markdown files to one big TS file with empty namespaces. It does not work if there are lists using * or block comments like /** ....

#!/bin/bash
# takes all the input files and places them within block comments
# on empty namespaces named the same as the filename (without the .md)
# and spits it out into stdout
# usage 'bash markdownToTs.sh *.md > someTsFile.ts'

while test $# -gt 0
do
    echo '/**'
    cat $1 
    echo '*/' 

    file_name=$1
    module_name=${file_name%???}    # remove .md ending
    echo "namespace $module_name {}"
    shift
done

For example for file test1.md:

# Test 1
- a 
- b
- c

it outputs:

/**
# Test 1
- a
- b
- c*/
namespace test1 {}

which is rendered as: image

jaykaron avatar Apr 04 '19 23:04 jaykaron

Another possible solution here:

  1. fork https://github.com/TypeStrong/typedoc-site and put your markdown doc in its _guides folder
  2. put your compiled typedoc output to api folder
  3. customize it for your project and release the whole jekyll site

Not much extra work required but get a perfectly look and unhacky results.

mlzxy avatar Jul 26 '19 02:07 mlzxy

Any news for a native way for this? This should be a must.

alexandercerutti avatar Feb 13 '20 13:02 alexandercerutti

This is next on my todo list once library mode (#1184) is done, but unfortunately I only have a couple hours a week to work on this project...

Gerrit0 avatar Feb 15 '20 20:02 Gerrit0

I wrote a TypeDoc plugin that I think might solve this need: https://github.com/mipatterson/typedoc-plugin-pages Live demo here

mipatterson avatar May 07 '20 04:05 mipatterson

Right now, I'm using this system, to convert files in a standard folder documents from markdown to html through marked.

Package.json:

{
	"scripts": {
		"predoc": "for f in $(find documents -type f | grep .md); do npx marked -i $f -o $(echo $f | sed -rne 's/.md/.html/p'); done",
		"doc": "rm -rf ./docs && npx typedoc"
	}
}

typedoc.json

{
    "media": "documents"
}

Then I'm referencing the files through [myFile](media://file.md). The only drawback is that markdown is not converted with a theme but as pure html.

alexandercerutti avatar Nov 25 '21 13:11 alexandercerutti

https://github.com/mipatterson/typedoc-plugin-pages looked perfect, but isn't compatible w/ v0.22 and seems abandoned. Anyone else know of a better alternative that supports pages?

tony-scio avatar May 04 '22 21:05 tony-scio

@tony-scio and all others, this seems to work pretty well: https://www.npmjs.com/package/@knodes/typedoc-plugin-pages

it's not defined as a theme but as a plugin, which is nice, because it actually allows to use any theme with the tutorials addition

dzek69 avatar Jul 21 '22 20:07 dzek69

yes, this works pretty well with 0.23.1: https://knodescommunity.github.io/typedoc-plugins/modules/_knodes_typedoc_plugin_pages.html

JinYi2000 avatar Oct 12 '22 10:10 JinYi2000

https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown is another option that looks well maintained. I'm using it for one of my projects at the moment.

transitive-bullshit avatar Nov 30 '22 22:11 transitive-bullshit

I have extra markdown files in my repository like CHANGELOG.md and CONTRIBUTING.md that I'd like to have converted to HTML along with the README.md (and ideally have links between the .md files changed to work - e.g. when README.md links to CHANGELOG.md, when both are converted to HTML the link to the changelog should still work).

josephearl avatar Sep 07 '23 14:09 josephearl

This feature is coming to 0.26, which is available to try in beta now: :tada: https://github.com/TypeStrong/typedoc/issues/2567

Gerrit0 avatar May 04 '24 16:05 Gerrit0