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

dataframes chapter update a table with commands #1437

Merged
merged 46 commits into from
Jun 7, 2024

Conversation

maxim-uvarov
Copy link
Contributor

I wrote a script to update the markdown table with commands. I'm not sure where to save it, as it might be useful for future updates. If anyone knows a proper place, please let me know. For now, I put it here.

let chapter = open dataframes.md
let book_table_str = $chapter 
    | lines 
    | skip until {|it| $it starts-with '| Command Name '} 
    | take until {|i| $i starts-with '## Future'}

let book_table = $book_table_str 
    | parse '| {command_name} | {applies_to} | {description} | {nushell_equivalent} |' 
    | skip 2 
    | str trim command_name nushell_equivalent 
    | rename name 
    | select name nushell_equivalent

let updated_table = help commands
    | where name =~ 'polars'
    | where name != 'polars'
    | update input_output {|i| $i.input_output.input | str join ', '}
    | select name input_output usage
    | join --left $book_table name
    | rename "Command Name" "Applies To" Description "Nushell Equivalent"
    | to md --pretty
    | str replace -ar "(( |-){47} \\|\n)" " \|\n"
    | $'($in)(char nl)'

$chapter | str replace ($book_table_str | str join (char nl)) $updated_table | save -f dataframes.md

@maxim-uvarov maxim-uvarov marked this pull request as ready for review June 4, 2024 11:29
@ayax79
Copy link
Contributor

ayax79 commented Jun 4, 2024

The pull request looks good. I'll let @fdncred on the best place to save your script.

@fdncred
Copy link
Collaborator

fdncred commented Jun 5, 2024

@hustcer Thoughts on this PR? Is it ok to land it or will the docs script rewrite it? Where should the script be placed?

@maxim-uvarov
Copy link
Contributor Author

The docs script never replaced the previous version of the table. Probably, it doesn't work with this kind of inline tables.

@hustcer
Copy link
Collaborator

hustcer commented Jun 6, 2024

Thanks,I will look into it later

@maxim-uvarov
Copy link
Contributor Author

My script does two things:

  1. Updates the table with the current list of polars commands.
  2. Joins the updated table with the currently specified values in the Nushell Equivalent column of the current markdown table.

I put this script in the comment so that the next person who updates the chapter will have a chance to use it.

Please let me know if it is not okay. I will delete my comments from there.

@hustcer
Copy link
Collaborator

hustcer commented Jun 6, 2024

@maxim-uvarov I have just added the tools folder, maybe we can put the script there.

@maxim-uvarov
Copy link
Contributor Author

@maxim-uvarov I have just added the tools folder, maybe we can put the script there.

@hustcer Thank you! I have moved the script there.

It should be okay to merge now. Gentlemen, please check.

@hustcer hustcer merged commit 634e3e0 into nushell:main Jun 7, 2024
2 checks passed
@hustcer
Copy link
Collaborator

hustcer commented Jun 7, 2024

Thanks

@maxim-uvarov maxim-uvarov deleted the df-update-table branch June 7, 2024 11:55
maxim-uvarov added a commit to maxim-uvarov/nushell.github.io that referenced this pull request Jun 16, 2024
The last time I put the file into the root directory by mistake
nushell#1437
fdncred pushed a commit that referenced this pull request Jun 16, 2024
The last time I put the file into the root directory by mistake
#1437
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.

None yet

4 participants