[MERGE] Document code layout stuff

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Sep 5 07:22:01 BST 2007


>>>>> "mbp" == Martin Pool <mbp at sourcefrog.net> writes:

    mbp> This changes the developer guide to be more specific
    mbp> about how things should be spaced/indented.

Great.

    mbp> There have been a few cases where reviewers have said
    mbp> "please do X" when pep8 doesn't (or doesn't clearly)
    mbp> require X.  abentley, lifeless and spiv said on irc that
    mbp> they agree with these rules (if I've captured them
    mbp> accurately).

I agree that they capture most of the remarks. Now we may want to
decide how to apply them to the code base but still avoid to make
life harder for long lived branches.

One way to do it may be to identify all problematic files and
commit them sloooowly (one by one once in a while or whatever) to
minimize spurious conflicts.

Once all the code base is correct, an automatic gate keeper will
be necessary (aaron's cdiff --style comes to mind).

    mbp> # Bazaar merge directive format 2 (Bazaar 0.90)
    mbp> # revision_id: mbp at sourcefrog.net-20070905051221-ubcur9dfodsozr28
    mbp> # target_branch: http://bazaar-vcs.org/bzr/bzr.dev
    mbp> # testament_sha1: e0d82bf9f11d46a0819058767fbb30165de71064
    mbp> # timestamp: 2007-09-05 15:23:09 +1000
    mbp> # source_branch: http://sourcefrog.net/bzr/doc
    mbp> # base_revision_id: pqm at pqm.ubuntu.com-20070905001648-0iigag4tq1u8mywn
    mbp> # 
    mbp> # Begin patch
    mbp> === modified file 'doc/developers/HACKING.txt'
    mbp> --- doc/developers/HACKING.txt	2007-08-28 06:59:20 +0000
    mbp> +++ doc/developers/HACKING.txt	2007-09-05 05:12:21 +0000
    mbp> @@ -624,12 +624,64 @@
    mbp>  Coding Style Guidelines
    mbp>  =======================
 
    mbp> +Code layout
    mbp> +-----------
    mbp> +
    mbp>  Please write PEP-8__ compliant code.  
 
    mbp> +__ http://www.python.org/peps/pep-0008.html
    mbp> +
    mbp>  One often-missed requirement is that the first line of docstrings
    mbp>  should be a self-contained one-sentence summary.
 
    mbp> -__ http://www.python.org/peps/pep-0008.html
    mbp> +We use 4 space indents for blocks, and never use tab characters.  (In vim,
    mbp> +``set expandtab``.)

bb: tweak

In emacs:

;(defface my-invalid-face
;  '((t (:background "Red" :underline t)))
;  "Face used to highlight invalid constructs or other uglyties"
;  )

(defun my-python-mode-hook ()
  ;; setup preferred indentation style.
  (setq fill-column 79)
  (setq indent-tabs-mode nil) ; no tabs, never, I will not repeat
;  (font-lock-add-keywords 'python-mode
;			  '(("^\\s *\t" . 'my-invalid-face) ; Leading tabs
;                            ("[ \t]+$" . 'my-invalid-face)  ; Trailing spaces
;                            ("^[ \t]+$" . 'my-invalid-face)); Spaces only
;                          )
  )

(add-hook 'python-mode-hook 'my-python-mode-hook)

The lines beginning with ';' are comments. They can be activated
if one want to have a strong notice of some tab/space usage
violations.

<snip/>

        Vincent



More information about the bazaar mailing list