docusaurus-theme-openapi-docs 0.0.0-394 → 0.0.0-397

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/lib/theme/ApiDemoPanel/CodeTabs/index.js +8 -3
  2. package/lib/theme/ApiItem/Content/index.js +65 -0
  3. package/lib/theme/ApiItem/Footer/index.js +78 -0
  4. package/lib/theme/ApiItem/Footer/styles.module.css +18 -0
  5. package/lib/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  6. package/lib/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  7. package/lib/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  8. package/lib/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  9. package/lib/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  10. package/lib/theme/ApiItem/Layout/index.js +93 -0
  11. package/lib/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +22 -0
  12. package/lib/theme/ApiItem/Metadata/index.js +32 -0
  13. package/lib/theme/ApiItem/Paginator/index.js +33 -0
  14. package/lib/theme/ApiItem/TOC/Desktop/index.js +31 -0
  15. package/lib/theme/ApiItem/TOC/Mobile/index.js +35 -0
  16. package/lib/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  17. package/lib/theme/ApiItem/index.js +37 -126
  18. package/lib/theme/ApiTabs/index.js +6 -5
  19. package/lib/theme/SchemaTabs/index.js +6 -5
  20. package/lib-next/theme/ApiDemoPanel/CodeTabs/index.js +7 -6
  21. package/lib-next/theme/ApiItem/Content/index.js +55 -0
  22. package/lib-next/theme/ApiItem/Footer/index.js +88 -0
  23. package/lib-next/theme/ApiItem/Footer/styles.module.css +18 -0
  24. package/lib-next/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  25. package/lib-next/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  26. package/lib-next/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  27. package/lib-next/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  28. package/lib-next/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  29. package/lib-next/theme/ApiItem/Layout/index.js +69 -0
  30. package/lib-next/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +22 -0
  31. package/lib-next/theme/ApiItem/Metadata/index.js +21 -0
  32. package/lib-next/theme/ApiItem/Paginator/index.js +19 -0
  33. package/lib-next/theme/ApiItem/TOC/Desktop/index.js +22 -0
  34. package/lib-next/theme/ApiItem/TOC/Mobile/index.js +24 -0
  35. package/lib-next/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  36. package/lib-next/theme/ApiItem/index.js +31 -133
  37. package/lib-next/theme/ApiTabs/index.js +6 -5
  38. package/lib-next/theme/SchemaTabs/index.js +6 -5
  39. package/package.json +6 -6
  40. package/src/theme/ApiDemoPanel/CodeTabs/index.tsx +6 -5
  41. package/src/theme/ApiItem/Content/index.tsx +57 -0
  42. package/src/theme/ApiItem/Footer/index.tsx +101 -0
  43. package/src/theme/ApiItem/Footer/styles.module.css +18 -0
  44. package/src/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  45. package/src/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  46. package/src/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  47. package/src/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  48. package/src/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  49. package/src/theme/ApiItem/Layout/index.tsx +78 -0
  50. package/src/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +22 -0
  51. package/src/theme/ApiItem/Metadata/index.tsx +24 -0
  52. package/src/theme/ApiItem/Paginator/index.tsx +21 -0
  53. package/src/theme/ApiItem/TOC/Desktop/index.tsx +25 -0
  54. package/src/theme/ApiItem/TOC/Mobile/index.tsx +28 -0
  55. package/src/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  56. package/src/theme/ApiItem/index.tsx +31 -130
  57. package/src/theme/ApiTabs/index.js +6 -5
  58. package/src/theme/SchemaTabs/index.js +6 -5
@@ -8,27 +8,16 @@
8
8
  import React from "react";
9
9
 
10
10
  import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
11
- import {
12
- PageMetadata,
13
- HtmlClassNameProvider,
14
- ThemeClassNames,
15
- useWindowSize,
16
- } from "@docusaurus/theme-common";
17
- import DocBreadcrumbs from "@theme/DocBreadcrumbs";
11
+ import { HtmlClassNameProvider } from "@docusaurus/theme-common";
18
12
  import type { Props } from "@theme/DocItem";
19
- import DocItemFooter from "@theme/DocItemFooter";
20
- import DocPaginator from "@theme/DocPaginator";
21
- import DocVersionBadge from "@theme/DocVersionBadge";
22
- import DocVersionBanner from "@theme/DocVersionBanner";
23
- import Heading from "@theme/Heading";
24
- import MDXContent from "@theme/MDXContent";
25
- import TOC from "@theme/TOC";
26
- import TOCCollapsible from "@theme/TOCCollapsible";
27
13
  import clsx from "clsx";
28
14
  import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/lib/types";
29
15
 
30
16
  import { DocFrontMatter } from "../../types";
31
- import styles from "./styles.module.css";
17
+ import DocItemLayout from "./Layout";
18
+ import DocItemMetadata from "./Metadata";
19
+
20
+ const { DocProvider } = require("@docusaurus/theme-common/internal");
32
21
 
33
22
  let ApiDemoPanel = (_: { item: any; infoPath: any }) => (
34
23
  <div style={{ marginTop: "3.5em" }} />
@@ -41,125 +30,37 @@ interface ApiFrontMatter extends DocFrontMatter {
41
30
  readonly api?: ApiItemType;
42
31
  }
43
32
 
44
- function DocItemMetadata(props: Props): JSX.Element {
45
- const { content: DocContent } = props;
46
- const { metadata, frontMatter, assets } = DocContent;
47
- const { keywords } = frontMatter;
48
- const { description, title } = metadata;
49
- const image = assets.image ?? frontMatter.image;
50
-
51
- return <PageMetadata {...{ title, description, keywords, image }} />;
52
- }
53
-
54
- function DocItemContent(props: Props): JSX.Element {
55
- const { content: DocContent } = props;
56
- const { metadata, frontMatter } = DocContent;
57
- const {
58
- info_path: infoPath,
59
- hide_title: hideTitle,
60
- hide_table_of_contents: hideTableOfContents,
61
- toc_min_heading_level: tocMinHeadingLevel,
62
- toc_max_heading_level: tocMaxHeadingLevel,
63
- } = frontMatter as DocFrontMatter;
64
- const { title } = metadata;
65
-
66
- const { api } = frontMatter as ApiFrontMatter;
67
-
68
- // We only add a title if:
69
- // - user doesn't ask to hide it with front matter
70
- // - the markdown content does not already contain a top-level h1 heading
71
- const shouldAddTitle =
72
- !hideTitle && typeof DocContent.contentTitle === "undefined";
73
-
74
- const windowSize = useWindowSize();
75
-
76
- const canRenderTOC =
77
- !hideTableOfContents && DocContent.toc && DocContent.toc.length > 0;
78
-
79
- const renderTocDesktop =
80
- canRenderTOC && (windowSize === "desktop" || windowSize === "ssr");
81
-
82
- return (
83
- <div className="row">
84
- <div className={clsx("col", !hideTableOfContents && styles.docItemCol)}>
85
- <DocVersionBanner />
86
- <div className={styles.docItemContainer}>
87
- <article>
88
- <DocBreadcrumbs />
89
- <DocVersionBadge />
33
+ export default function DocItem(props: Props): JSX.Element {
34
+ const docHtmlClassName = `docs-doc-id-${props.content.metadata.unversionedId}`;
90
35
 
91
- {canRenderTOC && (
92
- <TOCCollapsible
93
- toc={DocContent.toc}
94
- minHeadingLevel={tocMinHeadingLevel}
95
- maxHeadingLevel={tocMaxHeadingLevel}
96
- className={clsx(
97
- ThemeClassNames.docs.docTocMobile,
98
- styles.tocMobile
99
- )}
100
- />
101
- )}
36
+ const DocContent = () => {
37
+ const MDXComponent = props.content;
38
+ const { frontMatter } = MDXComponent;
39
+ const { info_path: infoPath } = frontMatter as DocFrontMatter;
40
+ const { api } = frontMatter as ApiFrontMatter;
102
41
 
103
- <div
104
- className={clsx(
105
- ThemeClassNames.docs.docMarkdown,
106
- "theme-api-markdown",
107
- "markdown"
108
- )}
109
- >
110
- {/*
111
- Title can be declared inside md content or declared through
112
- front matter and added manually. To make both cases consistent,
113
- the added title is added under the same div.markdown block
114
- See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
115
- */}
116
- {shouldAddTitle && (
117
- <header>
118
- <Heading as="h1">{title}</Heading>
119
- </header>
120
- )}
121
- <MDXContent>
122
- <div className="row">
123
- <div className={clsx("col", api ? "col--7" : "col--12")}>
124
- <DocContent />
125
- </div>
126
- {api && (
127
- <div className="col col--5">
128
- <ApiDemoPanel item={api} infoPath={infoPath} />
129
- </div>
130
- )}
131
- </div>
132
- </MDXContent>
133
- </div>
134
- <div className={clsx("col", api ? "col--7" : "col--12")}>
135
- <DocItemFooter {...props} />
136
- </div>
137
- </article>
138
- <div className={clsx("col", api ? "col--7" : "col--12")}>
139
- <DocPaginator previous={metadata.previous} next={metadata.next} />
140
- </div>
42
+ return (
43
+ <div className="row">
44
+ <div className={clsx("col", api ? "col--7" : "col--12")}>
45
+ <MDXComponent />
141
46
  </div>
47
+ {api && (
48
+ <div className="col col--5">
49
+ <ApiDemoPanel item={api} infoPath={infoPath} />
50
+ </div>
51
+ )}
142
52
  </div>
143
- {renderTocDesktop && (
144
- <div className="col col--3">
145
- <TOC
146
- toc={DocContent.toc}
147
- minHeadingLevel={tocMinHeadingLevel}
148
- maxHeadingLevel={tocMaxHeadingLevel}
149
- className={ThemeClassNames.docs.docTocDesktop}
150
- />
151
- </div>
152
- )}
153
- </div>
154
- );
155
- }
53
+ );
54
+ };
156
55
 
157
- export default function DocItem(props: Props): JSX.Element {
158
- const docHtmlClassName = `docs-doc-id-${props.content.metadata.unversionedId}`;
159
56
  return (
160
- <HtmlClassNameProvider className={docHtmlClassName}>
161
- <DocItemMetadata {...props} />
162
- <DocItemContent {...props} />
163
- </HtmlClassNameProvider>
57
+ <DocProvider content={props.content}>
58
+ <HtmlClassNameProvider className={docHtmlClassName}>
59
+ <DocItemMetadata />
60
+ <DocItemLayout>
61
+ <DocContent />
62
+ </DocItemLayout>
63
+ </HtmlClassNameProvider>
64
+ </DocProvider>
164
65
  );
165
66
  }
@@ -14,16 +14,17 @@ import React, {
14
14
  useState,
15
15
  } from "react";
16
16
 
17
- import {
18
- duplicates,
19
- useScrollPositionBlocker,
20
- useTabGroupChoice,
21
- } from "@docusaurus/theme-common";
17
+ import { duplicates } from "@docusaurus/theme-common";
22
18
  import useIsBrowser from "@docusaurus/useIsBrowser";
23
19
  import clsx from "clsx";
24
20
 
25
21
  import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
26
22
 
23
+ const {
24
+ useScrollPositionBlocker,
25
+ useTabGroupChoice,
26
+ } = require("@docusaurus/theme-common/internal");
27
+
27
28
  // allowing customization
28
29
 
29
30
  function isTabItem(comp) {
@@ -14,16 +14,17 @@ import React, {
14
14
  useState,
15
15
  } from "react";
16
16
 
17
- import {
18
- duplicates,
19
- useScrollPositionBlocker,
20
- useTabGroupChoice,
21
- } from "@docusaurus/theme-common";
17
+ import { duplicates } from "@docusaurus/theme-common";
22
18
  import useIsBrowser from "@docusaurus/useIsBrowser";
23
19
  import clsx from "clsx";
24
20
 
25
21
  import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
26
22
 
23
+ const {
24
+ useScrollPositionBlocker,
25
+ useTabGroupChoice,
26
+ } = require("@docusaurus/theme-common/internal");
27
+
27
28
  // allowing customization
28
29
 
29
30
  function isTabItem(comp) {