-
Notifications
You must be signed in to change notification settings - Fork 394
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
help: output from i18n-like string file #2108
Comments
Some integration between core and docs would be cool for sure. At the moment the place where these 2 repos are the closest to meeting is in the intro and synposes of https://dvc.org/doc/command-reference. But keep in mind that even then they're not exactly the same: sometimes we (1) add/change text, and we also (2) reformat the usage block so that it fits well in the website. Example: $ dvc add -h
usage: dvc add [-h] [-q | -v] [-R] [--no-commit] [--external] [--glob]
[--file <filename>] [--desc <text>]
targets [targets ...]
Track data files or directories with DVC.
Documentation: <https://man.dvc.org/add>
positional arguments:
targets Input files/directories to add. |
So maybe it's viable to use python to grab the correct class and format its synopsis? I know that python has dynamic imports, because Django uses them extensively. |
It's worth noting that adding a feature to dvc.org that reads from DVC CLI during the build would add DVC and, by extension, Python as a build dependency of the site on all machines, local and cloud. The effects of depending on a whole other language ecosystem would add a large amount of complexity and possible build time to the site that I'm not sure we're currently able to handle. A possible alternative that avoids this drawback while keeping most advantages would be adding a "docs export" feature to the DVC CLI that dumps all help output to some parse-able text format like MD, JSON, or any structured text which would then be consumed in Gatsby as opposed to running the command during every build. Using this output as an intermediate step allows us to avoid the issue of adding a hard dependency on DVC itself while still easing the burden of doc writers and allowing for a "source of truth" on the DVC docs. This exported docs API also has the advantage of allowing other methods of consumption like generating minimal HTML or traditional manpages. As for the API's consumption on Gatsby, we could both read and inject the doc data in many ways. |
Using an output from DVC itself seems like a swell idea. I'm not aware of any per-release jobs we could piggy back on but @efiop would know better.
I'm not sure how GraphQL would help in this context -- perhaps you mean a resolver that embeds the result from a DVC-produced JSON or yaml? If so that sounds great. |
Exactly! It's often easier in Gatsby to go from source data to React template than from source data to a Remark operation, especially in cases where the data is used the same way each time. |
This was the idea a long time back, but IIRC the conclusion was that auto-generated help sucks and docs needed some flexibility CC @shcheklein . |
I agree for fully auto-generated docs, but the synopsis code blocks we're talking about here are effectively supposed to be a complete copy of the output of A workflow involving exporting help from DVC and checking the text output into Git has the benefit of any changes in the automatic output being visible by diff in the same Git workflow as normal code, including mandating multiple devs inspect any changes via the PR review process. |
They're not that exactly, see #2108 (comment) above. But probably not hard to filter into the desired format, which can be what we have now or something else. Maybe that should be the first thing to decide: What do we want to see (ideal) in the cmd ref docs? |
Side note: if we can neatly separate the help output into a data structure, we might be able to show it neatly on mobile phones without horizontal scrolling. If whatever library the DVC CLI is using for command line interface doesn't allow us to extract the several parts separately, parsing the output string may be tricky but arguably worth it. |
I wrote a zsh loop in for f in *.md ; do
cmd=${f:r}
echo $cmd
dvc ${cmd} --help > ${cmd}-help.txt
done to get all help text from DVC. (It gives error on |
@iesahin A shell script is a good idea, especially in regards to being the least intrusive to both projects. If we go this route, maybe we could have the functionality to update a single command's help text instead of having to re-run every command's help for every update. As far as post-processing, we have the choice of either doing some processing in the shell script, or having a lean shell script that simply pipes DVC's output while we do any transformations in Gatsby at build-time. I'm in favor of the latter, since it all has to become Node data in the end regardless. |
@rogermparent What I had in my mind is actually a more manual process, does the DVC team update the interface that frequently? Someone (e.g. I) can run a tool and check the differences in output, update markdown files or create tickets. I think a manual edit process will be needed in any case. Otherwise we can simply include Keeping a set of text files that contain If you would like a fully automated process, I agree that running this within Gatsby (and not creating another script dependency) is better, but I doubt (from the discussion above), @jorgeorpinel and @shcheklein is in favor of such an automated process. |
I suppose I would call what I was thinking "semi-automated", in that editors manually get dvc working on PATH and invoke the script to update the text files with the help info. From there, Gatsby would do basic transforms like intents and formatting.
Instead of having the script do diffing, I think we could just check these files in with Git. That way, we see these help file diffs in the same place as all the other code diffs. |
They barely ever review the help output of existing commands or options but commands and options often change, which causes all sort of UI text updates. Also we tend to review the descriptions in the docs and send a PR in core to make corresponding updates to the help output strings there.
This would be useful for i18n too. We'd need to check in the core repo to see what they think though. For now if the proposed automation can reliable perform the transformation explained in #2108 (comment) then it could definitely be interesting, but ideally it should also allow for updating the transformation rules easily, or apply certain exceptions (and not overcomplicate the process for contributors). |
VS Code Github interface is interesting 😄 It assigned this to me while trying to open.
It's possible to use I think I can write a diff and create issues script in a few hours. It can create issues automatically with the changed help text content in DVC |
A quick script as POC would be great! |
My 2cs - I think this is a very low priority ticket, guys. I would not worry about it for now. I don't remember we had too many problems synchronizing docs with CLI in that specific part. |
I wrote a script and sent a PR in #2207 but closed without merge: If needs arise we can use the script to get the differences in |
Can we close this now? @jorgeorpinel @shcheklein |
Since we have #2770 and iterative/dvc#5392 (comment) I'd vote to close this ticket. Or change it just in order to decide on this specific idea:
Cc @efiop WDYT? My spin on it is that DVC would actually read the strings from that external text file to print in help output. In the future it could even use it for other terminal output like error messages, even logging, etc. |
p.s. we'd need to transfer this over to the core |
I believe the question "should we merge help text output and cmd ref" is still open and will be decided by the core team. We can close this. @efiop |
Closing in favor of iterative/dvc#5392 (comment). |
UPDATE: Jump to #2108 (comment)
Hello there!
Updating the CLI help output for every command is a bummer, but it can be done automatically.
By adding special HTML comments which are read by a script, it's possible to inline the output of commands into the markdown.
For example, in content/docs/command-reference/params/index.md:
By traversing all files and looking for
<!-- DVC_HELP
comments, it's possible to run the specified command and inline its output in the markdown.This could be generated automatically with each build, or it could be a script that's run manually and updates everything (as long as
dvc
is in the PATH).@rogermparent thoughts?
The text was updated successfully, but these errors were encountered: