File size: 3,210 Bytes
a03b3ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<script lang="ts">
	export let fn: any;
	import anchor from "../assets/img/anchor.svg";
</script>

<!-- name, signature, description, params -->

<div class="obj" id={fn.slug}>
	<div class="flex flex-row items-center justify-between">
		<h3 class="group text-3xl font-light py-4">
			{fn.name}
			<a href="#{fn.slug}" class="invisible group-hover-visible"
				><img class="anchor-img" src={anchor} /></a
			>
		</h3>
	</div>

	{#if fn.override_signature}
		<div class="codeblock">
			<pre><code class="code language-python">{fn.override_signature}</code
				></pre>
		</div>
	{:else}
		<div class="codeblock">
			<pre><code class="code language-python"
					>{fn.parent}.<span>{fn.name}&lpar;</span
					><!--
        -->{#each fn.parameters as param}<!--
        -->{#if !("kwargs" in param) && !("default" in param) && param.name != "self"}<!--
            -->{param.name}, <!--
        -->{/if}<!--
        -->{/each}<!--  
        -->路路路<span
						>&rpar;</span
					></code
				></pre>
		</div>
	{/if}

	<h4
		class="mt-8 text-xl text-orange-500 font-light group"
		id="{fn.slug}-description"
	>
		Description
		<a href="#{fn.slug}-description" class="invisible group-hover-visible"
			><img class="anchor-img-small" src={anchor} /></a
		>
	</h4>
	<p class="mb-2 text-lg">{@html fn.description}</p>

	{#if fn.example}
		<h4
			class="mt-4 text-xl text-orange-500 font-light group"
			id="{fn.slug}-example-usage"
		>
			Example Usage
			<a href="#{fn.slug}-example-usage" class="invisible group-hover-visible"
				><img class="anchor-img-small" src={anchor} /></a
			>
		</h4>
		<div class="codeblock">
			<pre><code class="code language-python"
					>{@html fn.highlighted_example}</code
				></pre>
		</div>
	{/if}

	{#if (fn.parameters.length > 0 && fn.parameters[0].name != "self") || fn.parameters.length > 1}
		<h4
			class="mt-6 text-xl text-orange-500 font-light group"
			id="{fn.slug}-arguments"
		>
			Agruments
			<a href="#{fn.slug}-arguments" class="invisible group-hover-visible"
				><img class="anchor-img-small" src={anchor} /></a
			>
		</h4>

		<table class="table-fixed w-full leading-loose">
			<thead class="text-left">
				<tr>
					<th class="px-3 pb-3 font-semibold text-gray-700 w-2/5">Parameter</th>
					<th class="px-3 pb-3 font-semibold text-gray-700">Description</th>
				</tr>
			</thead>
			<tbody
				class=" rounded-lg bg-gray-50 border border-gray-100 overflow-hidden text-left align-top divide-y"
			>
				{#each fn.parameters as param}
					{#if param["name"] != "self"}
						<tr class="group hover:bg-gray-200/60 odd:bg-gray-100/80">
							<td class="p-3 w-2/5 break-words">
								<code class="block">
									{param["name"]}
								</code>
								<p class="text-gray-500 italic">{param["annotation"]}</p>
								{#if "default" in param}
									<p class="text-gray-500 font-semibold">
										default: {param["default"]}
									</p>
								{:else if !("kwargs" in param)}
									<p class="text-orange-600 font-semibold italic">required</p>
								{/if}
							</td>
							<td class="p-3 text-gray-700 break-words">
								<p>{@html param["doc"] || ""}</p>
							</td>
						</tr>
					{/if}
				{/each}
			</tbody>
		</table>
	{/if}
</div>