Skip to content

Commit

Permalink
feat: enable dotnet language docs (#558)
Browse files Browse the repository at this point in the history
Adds dotnet (csharp) to supported language list. Adds a new data
structure mapping language name to generated language filename, since
`dotnet` is the supported target and `csharp` is the language we
generate docs for.
  • Loading branch information
MrArnoldPalmer authored Nov 1, 2021
1 parent 64adcba commit 701c60f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/constants/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ export enum Language {
Java = "java",
}

export const languageFilename = {
[Language.TypeScript]: Language.TypeScript,
[Language.Python]: Language.Python,
[Language.Go]: Language.Go,
[Language.Java]: Language.Java,
[Language.DotNet]: "csharp",
};

/**
* The sorted list of all available languages.
*/
Expand All @@ -37,6 +45,7 @@ export const TEMP_SUPPORTED_LANGUAGES: ReadonlySet<Language> = new Set([
Language.Python,
Language.TypeScript,
Language.Java,
Language.DotNet,
]);

export const LANGUAGE_RENDER_MAP: {
Expand Down
10 changes: 8 additions & 2 deletions src/views/Package/Package.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fetchAssembly } from "../../api/package/assembly";
import { fetchMarkdown } from "../../api/package/docs";
import { fetchMetadata } from "../../api/package/metadata";
import { Page } from "../../components/Page";
import { Language } from "../../constants/languages";
import { Language, languageFilename } from "../../constants/languages";
import { QUERY_PARAMS } from "../../constants/url";
import { useConfig } from "../../contexts/Config";
import { useLanguage } from "../../hooks/useLanguage";
Expand Down Expand Up @@ -44,7 +44,13 @@ export const Package: FunctionComponent = () => {
}, [name, requestAssembly, requestMetadata, scope, version]);

useEffect(() => {
void requestMarkdown(name, version, language, scope, submodule);
void requestMarkdown(
name,
version,
languageFilename[language],
scope,
submodule
);
}, [name, scope, version, language, submodule, requestMarkdown]);

// Handle missing JSON for assembly
Expand Down
4 changes: 4 additions & 0 deletions src/views/Package/components/UseConstruct/UseConstruct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const getCodeSample = ({
` <version>${version}</version>`,
"</dependency>",
].join("\n");
} else if (language === Language.DotNet) {
const packageId = assembly.targets?.dotnet?.packageId;
if (!packageId) return undefined;
return `dotnet add package ${packageId} --version ${version}`;
}

return undefined;
Expand Down

0 comments on commit 701c60f

Please sign in to comment.