Revision 1ae17369

b/doc/design-query2.rst
284 284
  formatting any unknown types the same way as "other", which should be
285 285
  a string representation in most cases.
286 286

  
287
``doc`` (string)
288
  Human-readable description. Must start with uppercase character and
289
  must not end with punctuation or contain newlines.
290

  
287 291
.. TODO: Investigate whether there are fields with floating point
288 292
.. numbers
289 293

  
b/lib/objects.py
1415 1415
  @ivar name: Field name
1416 1416
  @ivar title: Human-readable title
1417 1417
  @ivar kind: Field type
1418
  @ivar doc: Human-readable description
1418 1419

  
1419 1420
  """
1420 1421
  __slots__ = [
1421 1422
    "name",
1422 1423
    "title",
1423 1424
    "kind",
1425
    "doc",
1424 1426
    ]
1425 1427

  
1426 1428

  
b/lib/query.py
93 93

  
94 94
FIELD_NAME_RE = re.compile(r"^[a-z0-9/._]+$")
95 95
TITLE_RE = re.compile(r"^[^\s]+$")
96
DOC_RE = re.compile(r"^[A-Z].*[^.,?!]$")
96 97

  
97 98
#: Verification function for each field type
98 99
_VERIFY_FN = {
......
307 308
    assert fdef.name and fdef.title, "Name and title are required"
308 309
    assert FIELD_NAME_RE.match(fdef.name)
309 310
    assert TITLE_RE.match(fdef.title)
311
    assert (fdef.doc is None or
312
            (DOC_RE.match(fdef.doc) and len(fdef.doc.splitlines()) == 1 and
313
             fdef.doc.strip() == fdef.doc))
310 314
    assert callable(fn)
311 315
    assert fdef.name not in result, \
312 316
           "Duplicate field name '%s' found" % fdef.name
......
360 364
  return objects.QueryFieldsResponse(fields=fdefs).ToDict()
361 365

  
362 366

  
363
def _MakeField(name, title, kind):
367
def _MakeField(name, title, kind, doc=None):
364 368
  """Wrapper for creating L{objects.QueryFieldDefinition} instances.
365 369

  
366 370
  @param name: Field name as a regular expression
367 371
  @param title: Human-readable title
368 372
  @param kind: Field type
373
  @param doc: Human-readable description
369 374

  
370 375
  """
371
  return objects.QueryFieldDefinition(name=name, title=title, kind=kind)
376
  return objects.QueryFieldDefinition(name=name, title=title, kind=kind,
377
                                      doc=doc)
372 378

  
373 379

  
374 380
def _GetNodeRole(node, master_name):

Also available in: Unified diff