Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #305 & #286 #375

Closed
wants to merge 54 commits into from
Closed

Fixes #305 & #286 #375

wants to merge 54 commits into from

Conversation

ProjGoodF
Copy link
Contributor

@ProjGoodF ProjGoodF commented May 23, 2019

Fixes #305
Fixes #286

@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 May 23, 2019 14:21 Inactive
@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 May 23, 2019 14:32 Inactive
@ProjGoodF ProjGoodF changed the title Fixes #305 Fixes #305 & #286 May 23, 2019
@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 May 23, 2019 14:58 Inactive
@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 May 23, 2019 15:00 Inactive
pages/doc.js Outdated Show resolved Hide resolved
@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 May 24, 2019 14:09 Inactive
@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 May 24, 2019 14:09 Inactive
@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 May 24, 2019 14:11 Inactive
@ProjGoodF
Copy link
Contributor Author

  • The file structure has been changed, for example, docs / commands-reference / cache / dir.
  • The sidebar.json structure has been greatly simplified.
  • The loadStateFromURL function has been rewritten from scratch, in our opinion it has become a little clearer

pages/doc.js Outdated Show resolved Hide resolved
pages/doc.js Outdated Show resolved Hide resolved
@ProjGoodF ProjGoodF requested a review from shcheklein June 27, 2019 09:55
package.json Outdated
@@ -26,6 +26,8 @@
"axios": "^0.19.0",
"babel-plugin-transform-define": "^1.3.1",
"color": "^3.0.0",
"eslint": "^5.16.0",
"eslint-plugin-react": "^7.13.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are they used somewhere now? what about lodash - we removed it below, should we remove it from the package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we installed it for ourselves, we want to set up a beautiful code for your code style

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be done as a separate discussion, separate PR. let's remove it from this PR for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

pages/doc.js Outdated
import { scroller, animateScroll } from 'react-scroll'
import 'core-js/fn/array/find-index'
// styles
import styled from 'styled-components'
import { media } from '../src/styles'
// json
import sidebar from '../src/Documentation/sidebar'
import SidebarMenuHelper from '../src/Documentation/SidebarMenu/SidebarMenuHelper'
import { PATH_SEPARATOR } from '../src/Documentation/SidebarMenu/SidebarMenuHelper'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks a bit too much, it's always '/' - it's easier to use just plain '/' everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

pages/doc.js Outdated
}
let path = window.location.pathname.split(PATH_SEPARATOR)
let length = path.length
let { file, indexes } = SidebarMenuHelper.getFileFromUrl(path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this function actually return what is needed for the loadFile below? why should I care here about some indexes I don't know anything about. It looks like I care about section, subsection, and file. Let's return them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadFile works with files of different levels in sidebar.json, so this function needs all the information.

return `/doc/${compact([sectionSlug, fileSlug]).join('/')}`
getLinkHref = (section, subsection = null, file = null) => {
let sect = sidebar[section]
let removeExtFunc = filename =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just rename this function in the SideHelper in the first place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, is it fixed? forgot to push the changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, were not careful, renamed to SidebarHelper, now fix

</Menu>
)
}
renderSection = (section, file, index, fileIndex) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, add spaces between functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 June 28, 2019 02:18 Inactive
pages/doc.js Outdated
let subsect = sect.files[subsection]
let subfolder = subsect && subsect.folder
let folderpath = file.folder || subfolder || sect.folder
let filepath = file.indexFile || file.files || file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file.files[0]?

all these logic ^^ is still very complicated

can we make it always accept file as a file, not as a section or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can if we make the sidebar.json structure the same for any type of element

pages/doc.js Outdated
const subsectionSlug =
(subsection && removeExtFunc(sect.files[subsection].indexFile)) ||
sect.files[subsection]
const fileSlug = removeExtFunc(file) || (file && file.files[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

three lines above extremely hard to understand. For example why file is not actually file sometimes? is there a really strong reason here?

The same for subsection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When parsing, the next element in the sidebar.json structure may turn out to be a string, this is because each level may contain a different structure and a different set of fields.

pages/doc.js Outdated
this.setCurrentPath(
section,
subsection,
file.indexFile ? file.indexFile : file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ... is file or not? what is the reason to pass different structures around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

pages/doc.js Outdated
let subsect = sect.files[subsection]
let subfolder = subsect && subsect.folder
let folderpath = file.folder || subfolder || sect.folder
let filepath = file.indexFile || file.files || file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, previous lines are compilcated.

should it be actuallu files[0]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, is file.files a bug? should it be file.files[0]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used if the section (User Guide for example) does not contain its own root file, in which case the application suspects that the required file should be searched for in the attached file, and the latter may also be an object or a string.

array.forEach(elem => {
let path = SidebarMenuHelper.getFullPath(folder, elem)
if (path === currentFile) {
flag = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

during the passage of the array, in the end we need only the last value

.split(PATH_SEPARATOR)
.filter(_ => _)

static combineToPath = subPaths => [].concat(subPaths).join(PATH_SEPARATOR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious - why is [].concat(subPaths) needed? subPath is always non empty array, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will make function safe, exception won’t be thrown even if subPaths is null or undefined. May be it’s too much, agreed.

static findFileByName = (item, find) => {
let file = null
if (
SidebarMenuHelper.removeExtensionFromFileName(item.indexFile || item) ===
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install pre-commit hook and/or run prettier, it's > 80 symbols

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

his installed

@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 July 1, 2019 07:29 Inactive
@shcheklein shcheklein temporarily deployed to dvc-org-pr-375 July 1, 2019 07:53 Inactive
@shcheklein shcheklein closed this Jul 17, 2019
@shcheklein shcheklein deleted the gf-fix_#305_2 branch October 22, 2019 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support directories for the third level documentation confusing behavior on network fail
2 participants