reduce string manipulation

pull/3591/head
Joseph Izang 2 years ago committed by Aniket
parent 285cb5f17b
commit e872ef4b73
  1. 3
      apps/doc-gen/src/app/App.tsx
  2. 5
      apps/doc-gen/src/app/docgen-client.ts
  3. 2
      apps/doc-gen/src/app/docgen/utils/normalizeContractPath.ts
  4. 4
      apps/remix-ide/src/app/plugins/solidity-umlgen.tsx

@ -18,9 +18,8 @@ const App = () => {
setThemeType(theme)
})
client.eventEmitter.on('compilationFinished', (build: Build, fileName: string) => {
const temp = fileName.split('/')[fileName.split('/').length - 1]
setHasBuild(true)
setFileName(temp)
setFileName(fileName)
})
client.eventEmitter.on('docsGenerated', (docs: string[]) => {
})

@ -49,7 +49,7 @@ export class DocGenClient extends PluginClient {
output: output
}
const test = normalizeContractPath(fileName, true)
this.fileName = typeof test === 'string' ? test : test[1]
this.fileName = typeof test === 'string' ? test : test[test.length - 1]
this.contractPath = typeof test === 'object' ? test[0] : ''
this.eventEmitter.emit('compilationFinished', this.build, this.fileName)
})
@ -63,8 +63,7 @@ export class DocGenClient extends PluginClient {
const renderedSite = render(site, templates, config.collapseNewlines)
const docs: string[] = []
for (const { id, contents } of renderedSite) {
const pathArray = this.fileName.split('/')
const temp = `${pathArray[pathArray.length - 1]}.${id.split('.')[1]}`
const temp = `${this.fileName}.${id.split('.')[1]}`
const newFileName = `docs/${temp}`
await this.call('fileManager', 'setFile', newFileName , contents)
docs.push(newFileName)

@ -10,7 +10,7 @@ export function normalizeContractPath(contractPath: string, returnPath?: boolean
}
const resultingPath = `${folders}${filename}`
if(returnPath) {
return [folders,resultingPath]
return [folders,resultingPath, filename]
} else {
return resultingPath
}

@ -140,9 +140,7 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
* @returns {Promise<string>}
*/
async flattenContract (source: any, filePath: string, data: any) {
const appendage = '_flattened.sol'
const temp = await this.call('contractflattener', 'flattenContract', source, filePath, data)
const result = `${temp}${appendage}`
const result = await this.call('contractflattener', 'flattenContract', source, filePath, data)
return result
}

Loading…
Cancel
Save