difft::parse

Module guess_language

Source
Expand description

Guess which programming language a file is written in.

This is heavily based on GitHub’s linguist, particularly its languages.yml.

Difftastic does not reuse languages.yml directly. Linguist has a larger set of language detection strategies.

StructsΒ§

EnumsΒ§

  • Language πŸ”’
    Languages supported by difftastic. Each language here has a corresponding tree-sitter parser.
  • LanguageOverride πŸ”’
    Users can explicitly request to treat a certain file glob pattern as a specific languages, rather than using the normal language detection logic.

FunctionsΒ§

  • Try to guess the language based on an Emacs mode comment at the beginning of the file.
  • from_glob πŸ”’
  • from_shebang πŸ”’
    Try to guess the language based on a shebang present in the source.
  • guess πŸ”’
  • language_globs πŸ”’
    File globs that identify languages based on the file path.
  • language_name πŸ”’
    The language name shown to the user.
  • If there is a language called name (comparing case insensitively), return it. Treat "text" as an additional option.
  • looks_like_objc πŸ”’
    Use a heuristic to determine if a β€˜.h’ file looks like Objective-C. We look for a line starting with β€˜#import’, β€˜@interface’ or β€˜@protocol’ near the top of the file. These keywords are not valid C or C++, so this should not produce false positives.
  • looks_like_xml πŸ”’