<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Julia Community 🟣: Daniel VandenHeuvel</title>
    <description>The latest articles on Julia Community 🟣 by Daniel VandenHeuvel (@danielvandh).</description>
    <link>https://forem.julialang.org/danielvandh</link>
    <image>
      <url>https://forem.julialang.org/images/x0e3Ppz4JvgwL_HxzVA2kI76Kd5F92ofAdqGpgDzA7Y/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L3VzZXIvcHJvZmls/ZV9pbWFnZS8xNTA4/LzdiOWY5NjIyLWMy/OGMtNGZjZS05ODI4/LTQyZDA3MzY0ODlk/Yy5wbmc</url>
      <title>Julia Community 🟣: Daniel VandenHeuvel</title>
      <link>https://forem.julialang.org/danielvandh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.julialang.org/feed/danielvandh"/>
    <language>en</language>
    <item>
      <title>Efficiently fixing typos in documentation</title>
      <dc:creator>Daniel VandenHeuvel</dc:creator>
      <pubDate>Mon, 02 Oct 2023 01:20:30 +0000</pubDate>
      <link>https://forem.julialang.org/danielvandh/efficiently-fixing-typos-in-documentation-1j88</link>
      <guid>https://forem.julialang.org/danielvandh/efficiently-fixing-typos-in-documentation-1j88</guid>
      <description>&lt;p&gt;It is not uncommon to encounter typos in documentation for Julia packages. Fixing them as you happen to encounter them is simple for packages you own, but for other people's packages this is not so easy as (1) you can't make the commits directly and (2) you don't want to just spam them with pull requests fixing every typo individually when you see them. Moreover, especially for larger packages, it is just not possible to find all typos yourself. A great tool for optimising this process is &lt;code&gt;github-spellcheck&lt;/code&gt;, from &lt;a href="https://github.com/tbroadley/github-spellcheck-cli"&gt;tbroadley on GitHub&lt;/a&gt;, which checks a given GitHub repository for mistakes and will automatically create a pull request to fix them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing &lt;code&gt;github-spellcheck&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;github-spellcheck&lt;/code&gt; requires that you have Git, Node.js, and NPM all installed. In the instructions that follow, and in the rest of this article since &lt;code&gt;github-spellcheck&lt;/code&gt; is a command line tool, we are running commands in the terminal, which on Windows is opened with the &lt;code&gt;Windows Key + R&lt;/code&gt; and then entering &lt;code&gt;cmd&lt;/code&gt; (alternatively, you can enter &lt;code&gt;wt&lt;/code&gt;). &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To install Git, you can follow the instructions &lt;a href="https://github.com/git-guides/install-git"&gt;here&lt;/a&gt;. You can verify that you have installed it correctly by seeing if &lt;code&gt;git version&lt;/code&gt; reports any information:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\User&amp;gt;git version
git version 2.39.1.windows.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can install Node.js from &lt;a href="https://nodejs.org/en/download"&gt;here&lt;/a&gt;. Similarly to Git, you can verify that you have installed it correctly by seeing &lt;code&gt;node -v&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\User&amp;gt;node -v
v18.16.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the above installation of Node.js, you should also now have NPM, as the installer contains the NPM package manager. To check this, do &lt;code&gt;npm -v&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\User&amp;gt;npm -v
9.5.1
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;If you still do not have NPM, review the instructions &lt;a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now with Git, Node.js, and NPM all correctly installed, &lt;code&gt;github-spellcheck&lt;/code&gt; can be installed. To install it, simply run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\User&amp;gt;npm install --global github-spellcheck-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which will automatically install the tool. If you have installed it correctly, you can run &lt;code&gt;github-spellcheck -h&lt;/code&gt; to see if the help prints, as below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forem.julialang.org/images/UVhaF-2pFwtpBwYbuyAZbKtnXn8lpFgPEFQtjalLb6c/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzLzVq/OWl0YWRjYTRqZXlk/Njg3b2h5LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://forem.julialang.org/images/UVhaF-2pFwtpBwYbuyAZbKtnXn8lpFgPEFQtjalLb6c/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzLzVq/OWl0YWRjYTRqZXlk/Njg3b2h5LnBuZw" alt="Output of github-spellcheck -h" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using &lt;code&gt;github-spellcheck&lt;/code&gt; for the first time
&lt;/h2&gt;

&lt;p&gt;The first time you use &lt;code&gt;github-spellcheck&lt;/code&gt;, you need to provide it certain permissions for your GitHub account. This is done using either a GitHub credential manager or an access token. Here, we will use an access token, following the instructions &lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens"&gt;here&lt;/a&gt;. Go to &lt;a href="https://github.com/settings/tokens"&gt;https://github.com/settings/tokens&lt;/a&gt; and click &lt;code&gt;Generate new token&lt;/code&gt; followed by &lt;code&gt;Generate new token (classic)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forem.julialang.org/images/ckx8AFOXxRZDpKd4Kx-yStEqZUpDQNkuBanuzF8A5ZQ/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL3ho/M3NkZWc3aGxiNDBp/dGNweWxlLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://forem.julialang.org/images/ckx8AFOXxRZDpKd4Kx-yStEqZUpDQNkuBanuzF8A5ZQ/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL3ho/M3NkZWc3aGxiNDBp/dGNweWxlLnBuZw" alt="Generating an access token" width="790" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the page that you are taken to, make a note of what the token is for, e.g. &lt;code&gt;Spellcheck CLI&lt;/code&gt;, and only click on the &lt;code&gt;repo&lt;/code&gt; scope. You can set the expiration date as you please, for example 7 days; you will need to generate another token if the token has expired. Once you are done, scroll to the bottom of the page to generate token, and copy-paste the token that you are given.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: You should treat this token as you would any other password. Do not share or display it anywhere. Some good recommendations about keeping the tokens secure are given &lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#keeping-your-personal-access-tokens-secure"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To now set this token up for &lt;code&gt;github-spellcheck&lt;/code&gt;, use &lt;code&gt;github-spellcheck -t GITHUB_TOKEN&lt;/code&gt;, where &lt;code&gt;GITHUB_TOKEN&lt;/code&gt; is the long token you copied above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\User&amp;gt;github-spellcheck -t GITHUB_TOKEN
Saved your GitHub token.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You are now ready to use &lt;code&gt;github-spellcheck&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing typos in a repository
&lt;/h2&gt;

&lt;p&gt;Let us now use &lt;code&gt;github-spellcheck&lt;/code&gt; to address typos in a GitHub repository. Here, the repository for &lt;a href="https://github.com/DanielVandH/NaturalNeighbours.jl"&gt;NaturalNeighbours.jl&lt;/a&gt; will be used as a reference. (This is a package which I already have write access to, but you can use it for other packages, e.g. I have used it to create &lt;a href="https://github.com/JuliaManifolds/Manopt.jl/pull/298"&gt;this PR in Manopt.jl&lt;/a&gt;, where I have no write access.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: After you use this tool once for a repository, if you try and use it again for the same repository it will error at the end due to &lt;a href="https://github.com/tbroadley/github-spellcheck-cli/issues/108"&gt;this issue&lt;/a&gt;, and you will lose all the changes you have made with no way to recover them. To allow yourself to use the tool again for the same repository, you need to go to &lt;code&gt;~/.github-spellcheck/UserName/&lt;/code&gt; and delete the folder corresponding to the package. For example, after running the examples below, I then manually delete the folder &lt;code&gt;C:\Users\User\.github-spellcheck\DanielVandH\NaturalNeighbours.jl&lt;/code&gt;. You also want to delete the branch corresponding to the created pull request (as the GitHub pull request will prompt you to do after the pull request has been merged).&lt;/p&gt;

&lt;p&gt;To run the tool on the repository &lt;a href="https://github.com/DanielVandH/NaturalNeighbours.jl"&gt;https://github.com/DanielVandH/NaturalNeighbours.jl&lt;/a&gt;, we want to make sure we also include any docstrings. By default, &lt;code&gt;github-spellcheck&lt;/code&gt; only searches for files ending in &lt;code&gt;.md&lt;/code&gt; or &lt;code&gt;.txt&lt;/code&gt;, so we need to tell it to also search for &lt;code&gt;.jl&lt;/code&gt; files. The command for this is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;github-spellcheck -r DanielVandH/NaturalNeighbours.jl -e md txt jl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which shows the output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forem.julialang.org/images/5O0KwA68dstjsZPmDRb1pMQ2jqjanp0EH7lW9Y5kGcc/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzLzYz/NGwyNnVweXJoamR6/ajB2Nm9qLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://forem.julialang.org/images/5O0KwA68dstjsZPmDRb1pMQ2jqjanp0EH7lW9Y5kGcc/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzLzYz/NGwyNnVweXJoamR6/ajB2Nm9qLnBuZw" alt="Output from checking NaturalNeighbours.jl" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The main part of this output of interest is at the bottom. The tool is showing a typo highlighted in red, in this case we have a typo &lt;code&gt;Differentiaton&lt;/code&gt; in &lt;code&gt;docs/make.jl&lt;/code&gt;, and provides a recommendation &lt;code&gt;Differentiation&lt;/code&gt;. There are 7 instructions we can give in response to this, as indicated by &lt;code&gt;y, n, d, w, e, s, h&lt;/code&gt; at the bottom. The meaning of each of these instructions is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;y&lt;/code&gt;: Yes, apply this correction.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;n&lt;/code&gt;: No, do not apply this correction.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;d&lt;/code&gt;: Delete this word. This can be useful for duplicate words, e.g. if you have &lt;code&gt;the the&lt;/code&gt; then it will delete the second &lt;code&gt;the&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w&lt;/code&gt;: Add this typo to a whitelist, located at &lt;code&gt;~/.github-spellcheck/whitelist.txt&lt;/code&gt;, so that the tool will no longer apply any suggestions to this phrase. In this case, this would tell the tool to never prompt us about the word &lt;code&gt;Differentiaton&lt;/code&gt; again.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;e&lt;/code&gt;: Edit the correction suggested, replacing it with a different word.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;s&lt;/code&gt;: Skip this correction and any other corrections in this file, in this case &lt;code&gt;docs/make.jl&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;h&lt;/code&gt;: Print the help for these commands.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this case, we of course want to replace &lt;code&gt;Differentiaton&lt;/code&gt; by &lt;code&gt;Differentiaton&lt;/code&gt;, so we input &lt;code&gt;y&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forem.julialang.org/images/S1zwHpVS9G4c9EFsjhTq1YcRdndukjsGWhEaWFE9qN0/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL3hy/OXN4eHd6eDcyM3Zz/OG1vbWhoLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://forem.julialang.org/images/S1zwHpVS9G4c9EFsjhTq1YcRdndukjsGWhEaWFE9qN0/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL3hy/OXN4eHd6eDcyM3Zz/OG1vbWhoLnBuZw" alt="Making the first correction" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the first correction made, the tool goes onto the next correction. Here, it suggests that we replace &lt;code&gt;devbranch&lt;/code&gt; by &lt;code&gt;debranch&lt;/code&gt;, which is not what we want. We therefore input &lt;code&gt;w&lt;/code&gt; so that &lt;code&gt;devbranch&lt;/code&gt; is whitelisted and never asked about again. This whitelisting is also nice in case you make corrections against other repositories, since the tool will save these whitelisted words. &lt;/p&gt;

&lt;p&gt;Continuing with making changes, you may encounter suggestions that don't really fit what you want. For example, &lt;code&gt;arbitary&lt;/code&gt; will get replaced with &lt;code&gt;arbiter&lt;/code&gt; instead of &lt;code&gt;arbitrary&lt;/code&gt;. In this case, you should input &lt;code&gt;e&lt;/code&gt; and then input the word you want to use:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forem.julialang.org/images/kgZCO_uwOLWQoZ3W4FwjF6e2zzUs7zkVBjkEtfh_x5s/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL2Nw/M2xhc2tzcmF3Yjdh/NGg2c2xvLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://forem.julialang.org/images/kgZCO_uwOLWQoZ3W4FwjF6e2zzUs7zkVBjkEtfh_x5s/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL2Nw/M2xhc2tzcmF3Yjdh/NGg2c2xvLnBuZw" alt="Using the edit input" width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One unfortunate part about this process applied to the .jl files is that it will also try and apply corrections to code. There is no way in &lt;code&gt;github-spellcheck&lt;/code&gt; currently to apply e.g. a regex filter to these steps, so you will just need to keep whitelisting words until you find actual corrections to be made. For example, below it thinks that &lt;code&gt;d.interpolant&lt;/code&gt; should become &lt;code&gt;interpolant&lt;/code&gt;, which would not be a good suggestion as it will break the code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forem.julialang.org/images/k7AGvXGiQ-ZjAhRLoiBZt3rS8o21a7NJtHZAbyf8dVQ/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL2t1/dWRoMWJhYnh1cWsw/MGgybXZnLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://forem.julialang.org/images/k7AGvXGiQ-ZjAhRLoiBZt3rS8o21a7NJtHZAbyf8dVQ/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL2t1/dWRoMWJhYnh1cWsw/MGgybXZnLnBuZw" alt="A bad suggestion" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you are done making all the changes, the tool will list out all the changes made and ask if you are ready to create a pull request with these corrections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forem.julialang.org/images/mTAU-RD_Wlu4scL22ETLqJY-IYYXal5mMPdA-Hh4plE/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL2d1/Z3l1cXB0MmxkM2Jv/cm5rM252LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://forem.julialang.org/images/mTAU-RD_Wlu4scL22ETLqJY-IYYXal5mMPdA-Hh4plE/rt:fit/w:800/g:sm/mb:500000/ar:1/aHR0cHM6Ly9mb3Jl/bS5qdWxpYWxhbmcu/b3JnL3JlbW90ZWlt/YWdlcy91cGxvYWRz/L2FydGljbGVzL2d1/Z3l1cXB0MmxkM2Jv/cm5rM252LnBuZw" alt="Pull request confirmation" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are satisfied with the changes, input &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: There is no confirmation made in the browser after you input &lt;code&gt;y&lt;/code&gt;. It will just open up an already-created pull request. &lt;/p&gt;

&lt;p&gt;The pull request corresponding to the changes made to NaturalNeighbours.jl in this article is given &lt;a href="https://github.com/DanielVandH/NaturalNeighbours.jl/pull/21"&gt;here&lt;/a&gt;. The changes can then be reviewed and merged as with any normal pull request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The command line tool &lt;code&gt;github-spellcheck&lt;/code&gt; is a great way for fixing typos in packages. You do have to manually step through each change, which allows you better control over what changes are made, and the parsing of &lt;code&gt;jl&lt;/code&gt; files includes actual code, but the whitelisting features of &lt;code&gt;github-spellcheck&lt;/code&gt; helps to minimise these headaches. Happy spellchecking!&lt;/p&gt;

</description>
      <category>development</category>
      <category>github</category>
      <category>spelling</category>
      <category>typos</category>
    </item>
  </channel>
</rss>
