Skip to content

Define and maintain markdown documents through code.

License

Notifications You must be signed in to change notification settings

Andrchiamus/markdown-as-code

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-as-code

This project allows managing Markdown files through JavaScript/TypeScript

Table of Contents

Installation

Install using npm

npm i markdown-as-code

Install using pnpm

pnpm i markdown-as-code

Install using yarn

yarn add markdown-as-code

Run tests

npm t
# or
npm run test

Run Locally

  • Run the tests
pnpm t

Authors

Acknowledgements

Examples

Document Sections

Acknowledgements Class

import { Acknowledgements } from 'markdown-as-code';

const content = new Acknowledgements()
  .add({
    text: 'Acknowledgement',
    url: 'https://github.com',
  })
  .synthesize();

Acknowledgements Function

import { acknowledgementsSection } from 'markdown-as-code';

const content = acknowledgementsSection()
  .add({
    text: 'Acknowledgement',
    url: 'https://github.com',
  })
  .synthesize();

Api Reference Class

import { ApiReference } from 'markdown-as-code';

const content = new ApiReference()
  .add({
    title: 'Get all items',
    httpMethod: 'GET',
    path: '/api/items',
    parameter: {
      name: 'api_key',
      type: 'string',
      description: '**Required**. Your API key',
    },
  })
  .synthesize();

Api Reference Function

import { apiReferenceSection } from 'markdown-as-code';

const content = apiReferenceSection()
  .add({
    title: 'Get all items',
    httpMethod: 'GET',
    path: '/api/items',
    parameter: {
      name: 'api_key',
      type: 'string',
      description: '**Required**. Your API key',
    },
  })
  .synthesize();

Appendix Class

import { Appendix } from 'markdown-as-code';

const content = new Appendix().appendContent('Test content').synthesize();

Appendix Function

import { appendixSection } from 'markdown-as-code';

const content = appendixSection().appendContent('Test content').synthesize();

Authors Class

import { Authors } from 'markdown-as-code';

const content = new Authors()
  .add({ githubUsername: 'JaneDoe' })
  .add({ githubUsername: 'JohnSmith' })
  .synthesize();

Authors Function

import { authorsSection } from 'markdown-as-code';

const content = authorsSection()
  .add({ githubUsername: 'JaneDoe' })
  .add({ githubUsername: 'JohnSmith' })
  .synthesize();

Content Class

import { ContentSection } from 'markdown-as-code';

const content = new ContentSection('Test Section').synthesize();

Content Function

import { contentSection } from 'markdown-as-code';

const content = contentSection('Test Section').synthesize();

Contributing Class

import { Contributing } from 'markdown-as-code';

const content = new Contributing().synthesize();

Contributing Function

import { contributingSection } from 'markdown-as-code';

const content = contributingSection().synthesize();

Environment Variables Class

import { EnvironmentVariables } from 'markdown-as-code';

const content = new EnvironmentVariables()
  .add({
    name: 'API_KEY',
    defaultValue: 'YOUR-API-KEY-HERE',
  })
  .synthesize();

Environment Variables Function

import { environmentVariablesSection } from 'markdown-as-code';

const content = environmentVariablesSection()
  .add({
    name: 'API_KEY',
    defaultValue: 'YOUR-API-KEY-HERE',
  })
  .synthesize();

Examples Class

import { Examples } from 'markdown-as-code';

const content = new Examples()
  .add({
    title: 'Create an example section',
    description:
      'The title is defaulted to Examples but can be overridden in the constructor',
    codeblock: {
      language: 'typescript',
      code: 'const section = new Examples();',
    },
  })
  .synthesize();

Examples Function

import { examplesSection } from 'markdown-as-code';

const content = examplesSection()
  .add({
    title: 'Create an example section',
    description:
      'The title is defaulted to Examples but can be overridden in the constructor',
    codeblock: {
      language: 'typescript',
      code: 'const section = new Examples();',
    },
  })
  .synthesize();

Faq Class

import { FAQ } from 'markdown-as-code';

const content = new FAQ()
  .add({
    question: 'Question 1',
    answer: 'Answer 1',
  })
  .synthesize();

Faq Function

import { faqSection } from 'markdown-as-code';

const content = faqSection()
  .add({
    question: 'Question 1',
    answer: 'Answer 1',
  })
  .synthesize();

Installation Class

import { Installation } from 'markdown-as-code';

const content = new Installation()
  .add({
    command: 'npm i markdown-as-code',
    description: 'Install using npm',
  })
  .synthesize();

Installation Function

import { installationSection } from 'markdown-as-code';

const content = installationSection()
  .add({
    command: 'npm i markdown-as-code',
    description: 'Install using npm',
  })
  .synthesize();

Roadmap Class

import { Roadmap } from 'markdown-as-code';

const content = new Roadmap().add({ text: 'Item 1' }).synthesize();

Roadmap Function

import { roadmapSection } from 'markdown-as-code';

const content = roadmapSection().add({ text: 'Item 1' }).synthesize();

Run Locally Class

import { RunLocally } from 'markdown-as-code';

const content = new RunLocally()
  .add({
    command: 'npm t',
    description: 'Run the tests',
  })
  .synthesize();

Run Locally Function

import { runLocallySection } from 'markdown-as-code';

const content = runLocallySection()
  .add({
    command: 'npm t',
    description: 'Run the tests',
  })
  .synthesize();

Support Class

import { Support } from 'markdown-as-code';

const support = new Support().appendContent('Test content').synthesize();

Support Function

import { supportSection } from 'markdown-as-code';

const support = supportSection().appendContent('Test content').synthesize();

Table Of Contents Class

import { TableOfContentsSection, ContentSection } from 'markdown-as-code';

const content = new TableOfContentsSection({
  sections: [new ContentSection('Test Section')],
}).synthesize();

Table Of Contents Function

import { tableOfContentsSection, contentSection } from 'markdown-as-code';

const content = tableOfContentsSection({
  sections: [contentSection('Test Section')],
}).synthesize();

Documents

Markdown
import { createMarkdownDocument, ContentSection } from 'markdown-as-code';

const content = createMarkdownDocument({
  title: 'Test',
  fileName: 'test.md',
})
  .addSection(new ContentSection('Custom Section', 'Some markdown content'))
  .synthContent();
Readme
import { createReadmeDocument, ContentSection } from 'markdown-as-code';

const content = createReadmeDocument({
  title: 'Test',
  fileName: 'test.md',
})
  .addSection(new ContentSection('Custom Section', 'Some markdown content'))
  .synthContent();
Syntax Functions
Code Block
import { codeBlock } from 'markdown-as-code';

codeBlock({ language: 'typescript', code: 'const testNumber = 1' });
Heading
import { heading } from 'markdown-as-code';

heading(1, 'Heading Level 1');
heading(2, 'Heading Level 2');
heading(3, 'Heading Level 3');
heading(4, 'Heading Level 4');
heading(5, 'Heading Level 5');
heading(6, 'Heading Level 6');
Image
import { image } from 'markdown-as-code';

image('https://via.placeholder.com/150', 'Placeholder Image');
Link
import { link } from 'markdown-as-code';

link('Link Text', '');
List
import { orderedList, unorderedList, taskList } from 'markdown-as-code';

orderedList(['Item 1', 'Item 2', 'Item 3']);

unorderedList(['Item 1', 'Item 2', 'Item 3']);

taskList([
  { description: 'Task 1', complete: true },
  { description: 'Task 2', complete: false },
  { description: 'Task 3', complete: true },
]);
Mention
import { mentionPerson } from 'markdown-as-code';

mentionPerson('AllyMurray');
Quote
import { quote } from 'markdown-as-code';

quote('This is a quote');
Style
import { style } from 'markdown-as-code';

style('Bold', 'Example Bold Text');
style('Italic', 'Example Italic Text');
style('Strikethrough', 'Example Strikethrough Text');
style('Superscript', 'Example Superscript Text');
style('Subscript', 'Example Subscript Text');
style('BoldItalic', 'Example BoldItalic Text');

About

Define and maintain markdown documents through code.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%