Skip to content

Commit

Permalink
Merge pull request #647 from Krishanx92/newpub1
Browse files Browse the repository at this point in the history
Add documentation template for md
  • Loading branch information
Krishanx92 authored Mar 27, 2024
2 parents 2511684 + 3a27489 commit 457b6f7
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
"syntaxHighlighterProps": {
"showLineNumbers": false
},
"syntaxHighlighterDarkTheme": false
"syntaxHighlighterDarkTheme": false,
"templates": {
"howTo": "",
"sample": "",
"other": ""
}
},
"reactHTMLParser": {
"decodeEntries": true,
Expand Down
40 changes: 40 additions & 0 deletions portals/publisher/src/main/webapp/site/public/templates/howTo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# API Documentation

## Introduction

Briefly describe the purpose and scope of the API.

## Authentication

Explain how authentication is handled in the API, including any required headers, tokens, or OAuth flows.

## Base URL

Provide the base URL for all API endpoints.

## Rate Limiting

Describe any rate limiting policies applied to the API, including limits and error responses.

## Error Handling

Explain how errors are handled in the API, including error codes, messages, and examples.

## Versioning

Explain how versioning is managed in the API, including how clients can specify the API version.

## Endpoints

### Endpoint 1

- **URL:** `/endpoint-1`
- **Method:** GET
- **Description:** Describe what this endpoint does.
- **Parameters:**
- `param1`: Description of param1.
- **Request Example:**
```http
GET /endpoint-1?param1=value1 HTTP/1.1
Host: api.example.com
52 changes: 52 additions & 0 deletions portals/publisher/src/main/webapp/site/public/templates/other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Free Tier Details

## Overview

Provide a brief overview of the free tier, including its features, limitations, and benefits.

## Features

List the key features available in the free tier. For example:
- Limited access to certain services or features
- Usage limits (e.g., number of requests, storage limits)
- Support options (e.g., community support only)

## Limitations

Describe any limitations or restrictions of the free tier. For example:
- Limited scalability or performance compared to paid tiers
- Restrictions on usage (e.g., non-commercial use only)
- Lack of certain advanced features available in paid tiers

## Benefits

Highlight the benefits of using the free tier. For example:
- Opportunity to explore and test the service without cost
- Ideal for small projects or individuals with limited needs
- Easy upgrade path to paid tiers for additional features or resources

## Getting Started

Provide instructions on how to get started with the free tier. For example:
- Sign up for a free account
- Access the free tier services through the provided API or dashboard
- Review the documentation and tutorials for guidance

## Support

Describe the support options available for the free tier. For example:
- Community forums or knowledge base
- Email support for critical issues
- Premium support available with paid tiers

## Upgrade Options

Outline the upgrade options available for users who require additional features or resources beyond the free tier. For example:
- Upgrade to a paid tier with increased limits and additional features
- Choose a custom plan based on specific requirements
- Contact sales for enterprise or high-volume options

## Additional Resources

Provide links to additional resources, such as documentation, tutorials, and FAQs, to help users make the most of the free tier.

48 changes: 48 additions & 0 deletions portals/publisher/src/main/webapp/site/public/templates/sample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# API Documentation

## Endpoint

`GET /api/endpoint`

## Description

Provide a brief description of the endpoint and its purpose.

## Request

### Request URL

### Request Description

Provide a brief description of the request, explaining its purpose and any important details.

### Request Headers

- `Authorization`: Bearer token for authentication.

### Request Body

If the request includes a body, provide a sample body here.

## Response

### Response Code


### Response Headers

- `Content-Type`: application/json

### Response Body

Provide a sample response body here.

## Samples

### Curl Command

Provide a curl command that demonstrates how to make the same request from the command line.

```bash
curl -X GET https://api.example.com/api/endpoint -H "Authorization: Bearer <token>"

Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,19 @@ class Listing extends React.Component {
const docName = tableMeta.rowData[1];
const docId = tableMeta.rowData[0];
const sourceType = tableMeta.rowData[2];
const docType = tableMeta.rowData[3];
const sourceUrl = tableMeta.rowData[4];
if (sourceType === 'MARKDOWN') {
return (
<table className={classes.actionTable}>
<tr>
<td>
<MarkdownEditor docName={docName} docId={docId} apiId={this.apiId} />
<MarkdownEditor
docName={docName}
docId={docId}
apiId={this.apiId}
docType={docType}
/>
</td>
<td>
<Edit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* under the License.
*/

import React, { useState, useContext, Suspense, lazy } from 'react';
import React, { useState, useEffect, useContext, Suspense, lazy } from 'react';
import { useLocation } from 'react-router-dom';
import { styled } from '@mui/material/styles';
import { withRouter } from 'react-router-dom';
import { FormattedMessage, injectIntl } from 'react-intl';
Expand Down Expand Up @@ -87,21 +88,53 @@ function Transition(props) {
}

function MarkdownEditor(props) {
const location = useLocation();
const { doc } = location.state || {};
const skipHtml = Configurations.app.markdown ? Configurations.app.markdown.skipHtml : true;
const markdownSyntaxHighlighterProps = Configurations.app.markdown ?
Configurations.app.markdown.syntaxHighlighterProps: {};
const syntaxHighlighterDarkTheme = Configurations.app.markdown ?
Configurations.app.markdown.syntaxHighlighterDarkTheme: false;
const { intl, showAtOnce, history } = props;
const templateAvailble = Configurations.app.markdown && Configurations.app.markdown.template ? true : false
const howTotemplate = templateAvailble && Configurations.app.markdown.template.howTo ? Configurations.app.markdown.template.howTo : '';
const sampleTemplate = templateAvailble && Configurations.app.markdown.template.sample ? Configurations.app.markdown.template.sample : '';
const otherTemplate = templateAvailble && Configurations.app.markdown.template.other ? Configurations.app.markdown.template.other : '';
const { intl, showAtOnce, history, docType } = props;
const { api, isAPIProduct } = useContext(APIContext);
const [isUpdating, setIsUpdating] = useState(false);
const [open, setOpen] = useState(showAtOnce);
const [docContent, setDocContent] = useState(
intl.formatMessage({
id: 'documents.markdown.editor.default',
defaultMessage: '#Enter your markdown content',
}),
);
const [docContent, setDocContent] = useState();

useEffect(() => {
let templatePath = '';
if (howTotemplate && howTotemplate !== '' && ((doc && doc.type === 'HOWTO') || docType === 'HOWTO')) {
templatePath = `${Configurations.app.context}/site/public/templates/${howTotemplate}`;
} else if (sampleTemplate && sampleTemplate !== '' && ((doc && doc.type === 'SAMPLES') || docType === 'SAMPLES')) {
templatePath = `${Configurations.app.context}/site/public/templates/${sampleTemplate}`;
} else if (otherTemplate && otherTemplate !== '' && ((doc && doc.type === 'OTHER') || docType === 'OTHER')) {
templatePath = `${Configurations.app.context}/site/public/templates/${otherTemplate}`;
}

if (templatePath !== '') {
fetch(templatePath)
.then(response => {
if (!response.ok) {
throw new Error('Failed to fetch template');
}
return response.text();
})
.then(text => setDocContent(text))
.catch(error => console.error(error));
} else {
setDocContent(
intl.formatMessage({
id: 'documents.markdown.editor.default',
defaultMessage: '#Enter your markdown content',
})
);
}
}, [docType]);

const toggleOpen = () => {
if (!open) updateDoc();
if (open && showAtOnce) {
Expand Down

0 comments on commit 457b6f7

Please sign in to comment.