Giter Site home page Giter Site logo

kazydek / documentation-component Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kyma-incubator/documentation-component

0.0 1.0 0.0 4.63 MB

React component for rendering markdown, openapi, asyncapi and odata

License: Apache License 2.0

TypeScript 98.98% JavaScript 0.03% HTML 0.06% Makefile 0.01% CSS 0.03% SCSS 0.89%

documentation-component's Introduction

Documentation Component

Overview

The Documentation component is a generic, reusable React component that allows you to render any available specification formats.

It supports:

  • Passing custom functions that use system plugins to customize content rendering.
  • Passing custom render engines to render specific types of documents.
  • Setting custom architecture.

Quick start

To quickly start playing with the Documentation component, use one of these sandboxes:

Edit dc-with-all-render-engines - All the render engines in action, with navigation for multiple Markdown files.

Edit dc-with-nav-and-metadata-support - Plugins in action shown on the Markdown render engine. Support for rendering content from front matter and extending the UI navigation with it.

Installation

Run this command to install the component:

  • using npm

    npm i @kyma-project/documentation-component
  • using yarn

    yarn add @kyma-project/documentation-component

Usage

Learn what the component consists of and see the exemplary code.

Properties (props)

The list of properties for the Documentation component includes:

  • sources: (SourceWithOptions | SourceGroupWithOptions)[]

    The sources property is required and contains source files for the component. For more information on what a render engine is, read the sources.md document.

  • renderEngines: RenderEngines

    The renderEngines property is required and contains render engines for the component. For more information on what a render engine is, read the render-engines.md document.

    NOTE: The array must contain at least one value.

  • plugins?: Plugins

    The plugins property is optional and contains plugins for the component. For more information on what a plugin is, read the plugin.md document.

Custom render engine

For information on how to write a custom render engine for specific document types, read the custom-render-engine.md document.

Custom plugin

For information on how to write a custom plugin for specific document types, read the custom-plugin.md document.

Example

See an exemplary component code that renders the .md document source:

import React from "react";
import { render } from "react-dom";
import {
  DC,
  Content,
  Sources,
  RenderEngines,
  Plugins,
} from '@kyma-project/documentation-component';
import { markdownRenderEngine, plugins as markdownPlugins } from '@kyma-project/dc-markdown-render-engine';

const SOURCES: Sources = [
  {
    source: {
      type: "md",
      rawContent: "Example content",
    }
  }
]

const RENDER_ENGINES: RenderEngines = [
  markdownRenderEngine,
];

const PLUGINS: Plugins = [
  markdownPlugins.frontmatterMutationPlugin,
];

const App: React.FunctionComponent<> = () => (
  <DC.Provider
    sources={SOURCES}
    renderEngines={RENDER_ENGINES}
    plugins={PLUGINS}
  >
    <Content />
  </DC.Provider>
);

render(<App />, document.getElementById("root"));

Development

NOTE: This repository uses Yarn and Gulp for managing local dependencies and better development experience.

Prerequisites

Use the following tools to set up the project:

  • Node.js >= 10
  • Yarn

Installation

To install all dependencies for the Documentation component package and other packages in the packages directory, run these commands:

$ yarn install
$ yarn bootstrap

documentation-component's People

Contributors

magicmatatjahu avatar derberg avatar wawrzyn321 avatar tgorgol avatar klaudiagrz avatar hudymi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.