view doc/interpreter/doccheck/add_to_aspell_dict @ 22341:770fb2070e96

doc: Clean up tools used to check Texinfo documentation. * README: Update instructions * add_to_aspell_dict: Indent using 2 spaces. Use lower case for "aspell". * mk_undocumented_list: Add header explaining file. Indent using 2 spaces. Add comments explaining more of code. Add a newline to last line of any output. Remove deprecated functions from the exceptions list. * spellcheck: Indent using 2 spaces. Use lower case for "aspell".
author Rik <rik@octave.org>
date Thu, 18 Aug 2016 09:36:03 -0700
parents 0306e572c686
children 592fa741e0aa e9a0469dedd9
line wrap: on
line source

#!/usr/bin/perl -w

################################################################################
# File   : add_to_aspell_dict
# Purpose: Merges a file of new words into an existing dictionary file.
#          The resulting file is uniquified and sorted before being written out.
# Usage  : add_to_aspell_dict <filename_of_new_words>
# Documentation: see README in doccheck directory
################################################################################
# Initialize variables
# Private Octave dictionary for aspell
$octdict_fname = './doccheck/aspell-octave.en.pws';

################################################################################
# Parse command line arguments
unless (@ARGV == 1)
{
  die "USAGE: add_to_aspell_dict <filename_of_new_words>\n";
}

$new_words_fname = shift(@ARGV);
if (! -r $new_words_fname)
{
  die "Unable to read input file: $new_words_fname\n";
}

################################################################################
# Add new words to a dictionary database
open (FH, "<$new_words_fname")
  or die "Unable to open file: $new_words_fname\n";
while (<FH>) { $dict_db{$_} = 1; }
close (FH);

# Add words from existing dictionary to dictionary database
open (FH, "<$octdict_fname")
  or die "Unable to open Octave dictionary: $octdict_fname\n";
$header = <FH>;
while (<FH>) { $dict_db{$_} = 1; }
close (FH);

# Remove old dictionary file and write out new one
unlink ($octdict_fname)
  or die "Unable to delete Octave dictionary: $octdict_fname\n";
open (FH, ">$octdict_fname")
  or die "Unable to open file for writing: $octdict_fname\n";
print FH $header;
print FH sort { uc($a) cmp uc ($b) } keys(%dict_db);
close (FH);