Giter Site home page Giter Site logo

kyma-incubator / documentation-component Goto Github PK

View Code? Open in Web Editor NEW
8.0 15.0 9.0 2.67 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%
reactjs odata openapi asyncapi markdown

documentation-component's Introduction

Documentation Component

โš ๏ธ Archived

This project is discontinued and the repository has been deprecated and archived on Mar 7th, 2023.

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.

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

a-thaler avatar aerfio avatar derberg avatar desislavaa avatar hudymi avatar klaudiagrz avatar kwiatekus avatar magicmatatjahu avatar mmitoraj avatar ressetkk avatar tgorgol avatar wawrzyn321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

documentation-component's Issues

Fix headers extractor plugin

Description

Documentation component (exactly markdown-render-engine and his plugin headers-extractor) has a problem with only one instance of SourceWithOptions or SourceGroupWithOptions.

Expected result

Documentation component should work with one of above types with single instance.

Actual result

After passing one of above types with single instance, documentation component crash.

AsyncAPI Schema Validation fails

Description

With the latest update of @kyma-project/dc-async-api-render-engine in Kyma Console and Compass Console the Async API rendering stopped working.
I've given an example output in the Kyma Console UI in this issue.
The validation seems to fail for async APIs that have null fields like this one. On older versions of both consoles the APIs are rendered properly.

Expected result
The documents are rendered properly.

Actual result
The validation of fields fails.

Steps to reproduce

Described here

Troubleshooting

Make core independent from any JS lib/framework

Description

At the moment we have strongly coexisting with React ecosystem in our core. For easier integration in other frameworks (Angular and Vue ecosystem, and maybe also in SvelteJS) we must extract whole React from core and make it independent from any JS lib/framework.

Reasons

For easier integration in other JS frameworks/libs.

Odata component is broken with big spec

Description

After providing huge spec to odata component, the rendering of component throws error. Please see attachment below.

image

AC:

  • fix it (there is a problem with global state).

Expected result

Odata component works very well with huge spec.

Actual result

Odata component is broken when user provide spec with lots of data.

Steps to reproduce

Provide spec with lots of data to component.

Provide examples in JavaScript

Description

Reasons

At the moment all examples for the component are in TypeScript, except of sandbox projects.
Believe it or not, but there is still a great number of javascript developers that do not need TypeScript at all to write good quality code :D https://insights.stackoverflow.com/survey/2019#technology-_-programming-scripting-and-markup-languages

Write unit tests for documentation-component

Description

AC:

  • Write unit tests for documentation-component:
    • setup jest or another testing framework
    • a the moment test only core documentation-component and only core functionality, like a concatenating options, render content by render engines etc. - testing render engines will be done in next iteration.

Related issue(s):
kyma-project/kyma#4025

Make run* functions testable

Description

Right now all of the run* functions, like runExtractor for example, are not pure - they modify incoming objects, which makes is harder for us to test it

Reasons

Write better, more testable code

Attachments

No build for @kyma-project/dc-async-api-render-engine v0.3.5

Description

In kyma-incubator we use the @kyma-project/dc-async-api-render-engine lib. There was a vulnerability fix in our UI which bumps the @kyma-project/dc-async-api-render-engine to v0.3.5. But it seems like there are no output files in that build. When installing this version in our repo I see only the package.json and the README within the node modules.
image

Expected result

Have a good build with output js files.

Actual result

No minified file when the package is installed.

Steps to reproduce

Troubleshooting

Prepare release process for project

Description

AC:

  • Create release process for repository: include core documentation-component package and for others - render engines and for odata-react.
    • generate also changelog
  • Document release process in docs/development folder like here

Reasons

Attachments

Vulnerability in "merge" package

Description
There is a PR from some time ago regarding the package "merge". However, whitesource has been showing high vulnerability errors (CVE-2020-28499) in Compass Console for quite some time. If the PR is fine, can you merge it so we get rid of the error?
Thanks

Steps to exploit

Risk assessment

[{CVSS Vector String}]({CVSS Calculator URL}) {CVSS Base Score} ({CVSS Base Severity})

Proposed mitigation
Merge the PR

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.