fix tempates

pull/5370/head
filip mertens 2 years ago
parent e2dbb39d16
commit c085d9b66d
  1. 3
      apps/doc-gen/project.json
  2. 40
      apps/doc-gen/src/app/docgen/templates.ts
  3. 6
      apps/doc-gen/webpack.config.js

@ -42,7 +42,8 @@
"defaultConfiguration": "development",
"options": {
"buildTarget": "doc-gen:build",
"hmr": true
"hmr": true,
"baseHref": "/"
},
"configurations": {
"development": {

@ -1,7 +1,21 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { mapKeys } from './utils/map-keys';
import { DocItemContext } from './site';
import * as defaultProperties from './common/properties';
import * as themeHelpers from './themes/markdown/helpers'
const common = require('./themes/markdown/common.hbs');
const contract = require('./themes/markdown/contract.hbs');
const enum_ = require('./themes/markdown/enum.hbs');
const error = require('./themes/markdown/error.hbs');
const event = require('./themes/markdown/event.hbs');
const function_ = require('./themes/markdown/function.hbs');
const modifier = require('./themes/markdown/modifier.hbs');
const page = require('./themes/markdown/page.hbs');
const struct = require('./themes/markdown/struct.hbs');
const variable = require('./themes/markdown/variable.hbs');
const userDefinedValueType = require('./themes/markdown/user-defined-value-type.hbs');
export type PropertyGetter = (ctx: DocItemContext, original?: unknown) => unknown;
export type Properties = Record<string, PropertyGetter>;
@ -55,23 +69,29 @@ export async function readTemplates(): Promise<Required<Templates>> {
async function readPartials() {
const partials: NonNullable<Templates['partials']> = {};
const partialNames = ["common", "contract", "enum", "error", "event", "function", "modifier", "page", "struct", "variable", "user-defined-value-type"]
for (const name of partialNames) {
const p = await import(`raw-loader!${window.location.pathname}/themes/markdown/${name}.hbs`)
partials[name] = () => p.default
}
partials["common"] = () => common
partials["contract"] = () => contract
partials["enum"] = () => enum_
partials["error"] = () => error
partials["event"] = () => event
partials["function"] = () => function_
partials["modifier"] = () => modifier
partials["page"] = () => page
partials["struct"] = () => struct
partials["variable"] = () => variable
partials["user-defined-value-type"] = () => userDefinedValueType
return partials;
}
async function readHelpers(name: string) {
let helpersPath;
const h = await import(`${window.location.pathname}/themes/markdown/helpers`);
const helpers: Record<string, (...args: any[]) => any> = {};
for (const name in h) {
if (typeof h[name] === 'function') {
helpers[name] = h[name];
for (const name in themeHelpers) {
if (typeof themeHelpers[name] === 'function') {
helpers[name] = themeHelpers[name];
}
}

@ -37,6 +37,12 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
solc: 'solc',
}
config.module.rules.push({
test: /\.hbs$/,
type: 'asset/source'
})
// add public path
config.output.publicPath = '/'

Loading…
Cancel
Save