{"size": 4482, "ext": "js", "max_stars_repo_path": "docerina-ui/src/component/method.js", "max_stars_repo_name": "anupama-pathirage/ballerina-dev-tools", "max_stars_repo_stars_event_min_datetime": "2021-06-10T22:58:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-10T22:58:32.000Z", "max_issues_repo_path": "docerina-ui/src/component/method.js", "max_issues_repo_name": "anupama-pathirage/ballerina-dev-tools", "max_issues_repo_issues_event_min_datetime": "2020-11-30T10:16:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T18:53:53.000Z", "max_forks_repo_path": "docerina-ui/src/component/method.js", "max_forks_repo_name": "anupama-pathirage/ballerina-dev-tools", "max_forks_repo_forks_event_min_datetime": "2020-11-05T08:24:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T12:28:19.000Z"}
{"max_stars_count": 1, "max_issues_count": 97, "max_forks_count": 7, "avg_line_length": 48.1935483871, "max_line_length": 195, "alphanum_fraction": 0.4897367247}
/*
 *  Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */

import React from "react";
import { getTypeLabel } from "./helper"
import Markdown from "./markdown"
import { Link } from '../Router'

const Method = (props) => {
    return (
        <div className="method-content construct-page">
            <div className="main-method-title" id={props.method.name} title={props.method.name}>

                <h2 className={props.method.isDeprecated ? "strike" : ""}> {props.method.name} </h2>
            </div>
            <div>
                <pre className="method-signature">
                    <code className="break-spaces"><span className="token keyword">function</span> {props.method.name}(
            {props.method.parameters.length > 0 && props.method.parameters.map(param => { return [getTypeLabel(param.type), " " + param.name]; }).reduce((prev, curr) => [prev, ', ', curr])})
            {props.method.returnParameters.length > 0 && <span> <span className="token keyword">returns</span> {getTypeLabel(props.method.returnParameters[0].type)}</span>}
                    </code>
                </pre>
            </div>
            <div className="function-desc">
                {
                    props.method.isDeprecated == true &&
                    <div className="ui orange horizontal label">Deprecated</div>
                }
                {
                    props.method.isIsolated == true &&
                    <div className="ui horizontal label">Isolated Function</div>
                }
                {
                    props.method.isRemote == true &&
                    <div className="ui horizontal label">Remote Function</div>
                }
                <Markdown text={props.method.description} />
                {props.method.inclusionType != null && <p>Method included from <span data-tooltip="Type inclusion" data-position="top left">*</span>{getTypeLabel(props.method.inclusionType)}</p>}
            </div>
            {props.method.inclusionType == null &&
                <>
                    {props.method.parameters.length > 0 &&
                        <div className="parameters">
                            <h3 className="param-title">Parameters</h3>
                            {props.method.parameters.map(item => (
                                <div key={item.name} className="params-listing">
                                    <ul>
                                        <li>
                                            <span className={item.isDeprecated ? "strike" : ""}>{item.name}</span>
                                            <span className="type">  {getTypeLabel(item.type)} </span>
                                            {item.defaultValue != "" && <span className="default"> (default {item.defaultValue})</span>}
                                        </li>
                                        {
                                            item.isDeprecated == true &&
                                            <div className="ui orange horizontal label">Deprecated</div>
                                        }
                                        <Markdown text={item.description} />

                                    </ul>
                                </div>
                            ))}
                        </div>
                    }

                    {props.method.returnParameters.length > 0 &&
                        <div className="returns-listing">
                            <h3 className="type">Return Type</h3> (<span className="type">{getTypeLabel(props.method.returnParameters[0].type)}</span>)
                    <Markdown text={props.method.returnParameters[0].description} />
                        </div>
                    }
                </>
            }
        </div>
    );
}

export default Method;
