ietf-tools / idnits

Library / CLI to inspect Internet-Draft documents for a variety of conditions to conform with IETF policies.
BSD 3-Clause "New" or "Revised" License
12 stars 16 forks source link

Rewrite idnits as a JS library + CLI #24

Open NGPixel opened 1 year ago

NGPixel commented 1 year ago

This proposal is for a rewrite of idnits in javascript, so that it can run both natively in the browser and on the server / console.

General Implementation

Distribution

As a NPM package that can be both embedded into a web application or used as a standard CLI, on any platform supported by Node.js.

Arguments

Outdated | CLI mode | Library mode | Description | |--------------------|----------------------|-----------------------------------------------------------| | `--version` | N/A | Print the version and exit | | `--help` | N/A | Print the help text and exit | | `--nowarn` | `nowarn: false` | Don't issue warnings, only ID-Checklist violations | | `--verbose` | N/A | Show more information about offending lines | | `--nitcount` | N/A | Show a count of nits | | `--debug` | N/A | Debug output, especially of boilerplate matching | | `--year` | `year: 2023` | Expect the given year in the boilerplate | | `--checklistwarn` | N/A | Only warn (no errors) for ID-Checklist violations | | `--nonascii` | `noascii: false` | Disable warnings for non-ascii characters | | `--submitcheck` | `submitcheck: false` | Only output errors and warnings related to 1id-guidelines | | `--status doctype` | `status: 'doctype'` | Assume the given intended document type |

See README.md instead.

Returns

{
  result: string, // either "success" or "failed"
  file: {
    path: string, // Path of the document
    lines: Number, // Number of total lines processed
    size: Number // filesize in bytes
  },
  issues: [
    {
      lines: Array<Number>, // start and end line number (starts at 1), e.g. [1,5]
      message: string, // error message
      ref: string, // optional link reference
      level: string // either "warn" or "error"
    },
    ...
  ]
}

Web UI Mockup

The library could be integrated into a web app, allowing the user to browse for a document to validate. The document would be presented in a code editor like view, with warnings / errors shown on relevant lines (either inline or on the side).

ui-mockup

Breakdown of the Current Implementation

  1. starts at L3053
  2. calls check_line()
    1. check line length
    2. check line spacing
    3. check line ending with hyphenated word
    4. check ascii chars only and not ctrl chars
    5. check that abstract and "status of memo" are not numbered
    6. check RFC 2119 language
    7. check example domain names
    8. check ipv4 addresses
  3. calculate page count
  4. warn if draft starts with PK or BM
  5. normalize text and try a list of matches
    1. calls match_para()
  6. calls report()
    1. todo

Original idnits SOW

idnits-SOW-00.pdf