Skip to content

Commit

Permalink
refactoray
Browse files Browse the repository at this point in the history
  • Loading branch information
dhammena committed Mar 13, 2022
1 parent 922c01d commit 9cfc435
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 39 deletions.
3 changes: 2 additions & 1 deletion abbr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import fs from "fs";
import { render } from "template-file";

import { MakerBase } from "../common/classes";
import { IAbbr, IDictConf } from "../common/interfaces";
import { IDictConf } from "../common/interfaces";
import { GeneratorByHand } from "../common/jsonFileGenerator";
import { IAbbr } from "./interfaces";
import { FILENAME } from "../config";

export class Maker extends MakerBase {
Expand Down
5 changes: 5 additions & 0 deletions abbr/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface IAbbr {
abbr: string;
text: string;
type: string;
}
Binary file modified assets/abbr/dict.mdx
Binary file not shown.
Binary file modified assets/dppn/dict.mdx
Binary file not shown.
Binary file modified assets/ncped/dict.mdx
Binary file not shown.
Binary file modified assets/pts/dict.mdx
Binary file not shown.
28 changes: 5 additions & 23 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { IPts } from "../pts/interfaces";
import { IAbbr } from "../abbr/interfaces";
import { IDppn } from "../dppn/interfaces";
import { INcped } from "../ncped/interfaces";

export interface IDictConf {
jsonUrl?: string;
fullName: string;
Expand All @@ -15,29 +20,6 @@ export interface IFileName {
mdx: string; // result mdict file
}

export interface IPts {
word: string;
text: string;
}

export interface INcped {
entry: string;
grammar?: string;
definition?: string | string[];
xr?: string | string[]; // cross references
}

export interface IDppn {
word: string;
text: string;
}

export interface IAbbr {
abbr: string;
text: string;
type: string;
}

export type IEntry = IPts | INcped | IDppn | IAbbr;

export interface IJsonFileGenerator {
Expand Down
24 changes: 12 additions & 12 deletions config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import { IDictConf, IFileName as IFileName } from "./common/interfaces";

export const FILENAME: IFileName = {
entryTemplate: 'entry.html',
json: "dict.json",
css: "dict.css",
txt: "dict.txt",
title: "title.html",
description: "description.html",
mdx: "dict.mdx"
}
import { IDictConf, IFileName } from "./common/interfaces";

export enum DictEnum {
PTS = "pts",
Expand All @@ -17,9 +7,19 @@ export enum DictEnum {
ABBR = "abbr"
};

type dictionary = Record<DictEnum, IDictConf>;

export const ASSETS_DIR = `${__dirname}/assets`;

type dictionary = Record<DictEnum, IDictConf>
export const FILENAME: IFileName = {
entryTemplate: "entry.html",
json: "dict.json",
css: "dict.css",
txt: "dict.txt",
title: "title.html",
description: "description.html",
mdx: "dict.mdx",
};

export const DICTIONARY: dictionary = {
[DictEnum.PTS]: {
Expand Down
3 changes: 2 additions & 1 deletion dppn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import fs from "fs";
import { render } from "template-file";

import { MakerBase } from "../common/classes";
import { IDppn, IDictConf } from "../common/interfaces";
import { IDictConf } from "../common/interfaces";
import { GeneratorByDownload } from "../common/jsonFileGenerator";
import { IDppn } from "./interfaces";
import { FILENAME } from "../config";

export class Maker extends MakerBase {
Expand Down
4 changes: 4 additions & 0 deletions dppn/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IDppn {
word: string;
text: string;
}
3 changes: 2 additions & 1 deletion ncped/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import fs from "fs";
import { render } from "template-file";

import { MakerBase } from "../common/classes";
import { INcped, IDictConf } from "../common/interfaces";
import { IDictConf } from "../common/interfaces";
import { GeneratorByDownload } from "../common/jsonFileGenerator";
import { INcped } from "./interfaces";
import { FILENAME } from "../config";

export class Maker extends MakerBase {
Expand Down
6 changes: 6 additions & 0 deletions ncped/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface INcped {
entry: string;
grammar?: string;
definition?: string | string[];
xr?: string | string[]; // cross references
}
3 changes: 2 additions & 1 deletion pts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import fs from "fs";
import { render } from "template-file";

import { MakerBase } from "../common/classes";
import { IPts, IDictConf } from "../common/interfaces";
import { IDictConf } from "../common/interfaces";
import { GeneratorByDownload } from "../common/jsonFileGenerator";
import { IPts } from "./interfaces";
import { FILENAME } from "../config";

export class Maker extends MakerBase {
Expand Down
4 changes: 4 additions & 0 deletions pts/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IPts {
word: string;
text: string;
}

0 comments on commit 9cfc435

Please sign in to comment.