Skip to content

Commit 514206b

Browse files
committed
Add default values from inferapp
1 parent c90d57b commit 514206b

18 files changed

+11110
-0
lines changed

.eslintrc.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"plugin:react/recommended",
9+
"airbnb"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"ecmaVersion": 12,
17+
"sourceType": "module"
18+
},
19+
"plugins": [
20+
"react",
21+
"@typescript-eslint"
22+
],
23+
"rules": {
24+
"react/prop-types": "off",
25+
"react/react-in-jsx-scope": "off",
26+
"react/jsx-filename-extension": "off",
27+
"react/jsx-props-no-spreading": "off",
28+
"import/no-unresolved": "off",
29+
"import/extensions": "off"
30+
}
31+
}

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
![Tux, the Linux mascot](/assets/mintlify-green-smol.png)
2+
# Inferlang for Developers
3+
4+
Auto-detect the programming language of any code
5+
## API Endpoint
6+
7+
Use the Inferlang API to programmatically build language detection into your application
8+
9+
```bash
10+
POST: https://inferlang.com/api/detect
11+
```
12+
13+
| Request Body | |
14+
| ----------- | ----------- |
15+
| `code` (required) | Code input you would like to identify the language for as a string |
16+
17+
| Returns | |
18+
| ----------- | ----------- |
19+
| `language` | Name of the language detected |
20+
21+
## Running locally
22+
23+
You can run the Interlang app in your local machine
24+
25+
First, install the dependencies using
26+
27+
```bash
28+
npm install
29+
```
30+
31+
Then run the [Next.JS](https://nextjs.org/) application using
32+
33+
```bash
34+
npm run dev
35+
```
36+
37+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
38+
39+
## Learn More
40+
41+
Inferlang is powered by and [GuessLang](https://github.com/yoeo/guesslang) and hosted by [Mintlify](https://mintlify.ccom). You can find out more at
42+
43+
- [GuessLang Documentation](https://guesslang.readthedocs.io/en/latest/) - Guesslang detects the programming language of a given source code. It supports more than 50 programming languages and detects the correct programming language with more than 90% accuracy.
44+
45+
- [Mintlify Signup](https://nextjs.org/learn) - The search engine in your codebase
46+
47+
You can check out [the Inferlang repository](https://github.com/mintlify/inferapp) - your feedback and contributions are welcome!

assets/mintlify-green-smol.png

2.15 KB
Loading

assets/mintlify.svg

+5
Loading

components/CodeEditor.tsx

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* eslint-disable react/jsx-props-no-spreading */
2+
import Editor from 'react-simple-code-editor';
3+
import Highlight, { defaultProps, Language } from 'prism-react-renderer';
4+
import theme from 'prism-react-renderer/themes/nightOwl';
5+
6+
type CodeEditorProps = {
7+
code: string;
8+
// eslint-disable-next-line no-unused-vars
9+
setCode: (code: string) => void;
10+
placeholder: string;
11+
language: string;
12+
}
13+
14+
export default function CodeEditor({
15+
code, setCode, placeholder, language,
16+
}: CodeEditorProps) {
17+
const highlight = (codeUnhighlighted: string) => (
18+
<Highlight
19+
{...defaultProps}
20+
theme={theme}
21+
code={codeUnhighlighted}
22+
language={language.toLowerCase() as Language}
23+
>
24+
{({
25+
tokens, getLineProps, getTokenProps,
26+
}) => (
27+
<>
28+
{tokens.map((line, i) => (
29+
<div {...getLineProps({ line, key: i })}>
30+
{line.map((token, key) => <span {...getTokenProps({ token, key })} />)}
31+
</div>
32+
))}
33+
</>
34+
)}
35+
</Highlight>
36+
);
37+
38+
return (
39+
<Editor
40+
value={code}
41+
onValueChange={(codeUpdated) => setCode(codeUpdated)}
42+
highlight={highlight}
43+
padding={16}
44+
placeholder={placeholder}
45+
className="border border-gray-300 rounded-lg text-sm"
46+
style={{
47+
boxSizing: 'border-box',
48+
fontFamily: '"Dank Mono", "Fira Code", monospace',
49+
minHeight: '12rem',
50+
...theme.plain as any,
51+
}}
52+
/>
53+
);
54+
}

components/Output.tsx

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import toast from 'react-hot-toast';
2+
import { DuplicateIcon } from '@heroicons/react/outline';
3+
4+
type OutputProps = {
5+
output: string;
6+
isLoading: boolean;
7+
}
8+
9+
function Output(props: OutputProps) {
10+
const { output, isLoading } = props;
11+
12+
const copyToClipboard = () => {
13+
navigator.clipboard.writeText(output);
14+
toast.success('Copied to clipboard');
15+
};
16+
17+
return (
18+
<div className="relative bg-gray-100 border-2 border-gray-200 rounded-lg text-gray-700 p-4 pb-10" style={{ minHeight: '12rem' }}>
19+
<p className="whitespace-pre-line text-sm">{output}</p>
20+
{
21+
output && (
22+
<button className="absolute right-3 bottom-3" type="button" onClick={copyToClipboard}>
23+
<DuplicateIcon className="h-6 w-6 text-gray-600 hover:text-gray-400" />
24+
</button>
25+
)
26+
}
27+
{isLoading && (
28+
<div className="absolute inset-0 flex items-center justify-center">
29+
<svg className="animate-spin -ml-1 mr-3 h-5 w-5 text-gray-800" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
30+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
31+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
32+
</svg>
33+
</div>
34+
)}
35+
</div>
36+
);
37+
}
38+
39+
export default Output;

next-env.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />
3+
/// <reference types="next/image-types/global" />
4+
5+
// NOTE: This file should not be edited
6+
// see https://nextjs.org/docs/basic-features/typescript for more information.

next.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('next').NextConfig} */
2+
module.exports = {
3+
reactStrictMode: true,
4+
}

0 commit comments

Comments
 (0)