Skip to content

Commit

Permalink
Clarify wording of what lines need to be
Browse files Browse the repository at this point in the history
- Clarify that leading and trailing whitespace are ignored
  on all lines (so empty lines count as blank, which they technically
  did not before).
- Express the parsing logic imperatively to make it easier to read.
- Add links within the document from line types to relevant sections.
  • Loading branch information
cxw42 committed Sep 15, 2024
1 parent 014fdd4 commit 5df4933
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
copyright = '2019--2024, EditorConfig Team'
author = 'EditorConfig Team'

version = '0.16.0'
release = '0.16.0'
version = '0.16.1'
release = '0.16.1'

# -- General configuration ---------------------------------------------------

Expand Down
29 changes: 22 additions & 7 deletions index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. Copyright (c) 2019--2020 EditorConfig Team
.. Copyright (c) 2019--2024 EditorConfig Team
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -73,20 +73,31 @@ EditorConfig organization.
File Format
===========

.. versionchanged:: 0.16.1

EditorConfig files are in an INI-like file format.
In an EditorConfig file, all beginning whitespace on each line is considered
irrelevant. Each line must be one of the following:
To read an EditorConfig file, take one line at a time. For each line:

#. Strip all leading and trailing whitespace
#. If the remaining text is empty, ignore the line.
#. If the remaining text is not empty, process the text as specified for its
type below.

The types of lines are:

- Comment: starts with a ``;`` or a ``#``. Comment lines are ignored.

- Blank: contains only whitespace characters.
- Comment: starts with a ``;`` or a ``#``.
- Section Header: starts with a ``[`` and ends with a ``]``.
- May not use any non-whitespace characters outside of the surrounding
brackets.
These lines define globs; see :ref:`glob-expressions`.

- May contain any characters between the square brackets (e.g.,
``[`` and ``]`` and even spaces and tabs are allowed).
- Forward slashes (``/``) are used as path separators.
- Backslashes (``\\``) are not allowed as path separators (even on Windows).

- Key-Value Pair (or Pair): contains a key and a value, separated by an ``=``.
See :ref:`supported-pairs`.

- Key: The part before the first ``=`` (trimmed of whitespace, but including
any whitespace in the middle).
- Value: The part after the first ``=`` (trimmed of whitespace, but including
Expand Down Expand Up @@ -131,6 +142,8 @@ The parts of an EditorConfig file are:
- Section: the lines starting from a Section Header until the beginning of
the next Section Header or the end of the file.

.. _glob-expressions:

Glob Expressions
================

Expand Down Expand Up @@ -183,6 +196,8 @@ precedence. If multiple EditorConfig files have matching sections, the rules
from the closer EditorConfig file are read last, so pairs in closer
files take precedence.

.. _supported-pairs:

Supported Pairs
===============

Expand Down

0 comments on commit 5df4933

Please sign in to comment.