reduce string manipulation

pull/5370/head
Joseph Izang 2 years ago committed by Aniket
parent 5c41a8020e
commit d4251c72b3
  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) setThemeType(theme)
}) })
client.eventEmitter.on('compilationFinished', (build: Build, fileName: string) => { client.eventEmitter.on('compilationFinished', (build: Build, fileName: string) => {
const temp = fileName.split('/')[fileName.split('/').length - 1]
setHasBuild(true) setHasBuild(true)
setFileName(temp) setFileName(fileName)
}) })
client.eventEmitter.on('docsGenerated', (docs: string[]) => { client.eventEmitter.on('docsGenerated', (docs: string[]) => {
}) })

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

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

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

Loading…
Cancel
Save