Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function AvailableOperations({ operations }) {
<>
<Text newLines={2}>### Available Operations</Text>
{operations.map((operation) => (
<Text newLines={2}>
<Text key={operation.id()} newLines={2}>
<OperationHeader operation={operation} />
<MessageExamples operation={operation} />
</Text>
Expand Down
10 changes: 8 additions & 2 deletions packages/components/src/components/readme/Installation.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { Text } from '@asyncapi/generator-react-sdk';

export function Installation() {
const installCommands = {
python: 'pip install -r requirements.txt',
javascript: 'npm install',
};

export function Installation({ language }) {
const command = installCommands[language] || installCommands['python']; // default to python command
return (
<Text newLines={2}>
{`## Installation

Install dependencies:

\`\`\`bash
pip install -r requirements.txt
${command}
\`\`\`
`}
</Text>
Expand Down
8 changes: 3 additions & 5 deletions packages/components/src/components/readme/Readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@ export function Readme({ asyncapi, params, language }) {
const title = getTitle(asyncapi);
const serverUrl = getServerUrl(server);

const includeInstallation = language === 'python';
const includeAvailableOps = language === 'javascript';
const operations = includeAvailableOps ? asyncapi.operations().all() : [];
const operations = asyncapi.operations().all();

return (
<File name="README.md">
<Text newLines={2}>{`# ${title}`}</Text>
<Overview info={info} title={title} serverUrl={serverUrl} />
{includeInstallation && <Installation />}
<Installation language={language}/>
<Usage
clientName={clientName}
clientFileName={params.clientFileName}
language={language}
/>
<CoreMethods language={language} />
{includeAvailableOps && <AvailableOperations operations={operations} />}
{operations.length > 0 && <AvailableOperations operations={operations} />}
</File>
);
}
Expand Down
Loading