[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cleanups with long-term benefits (was Re: [PATCH] schemas: Add vim m

From: John Snow
Subject: Re: cleanups with long-term benefits (was Re: [PATCH] schemas: Add vim modeline)
Date: Mon, 3 Aug 2020 14:19:30 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 8/3/20 2:16 PM, Paolo Bonzini wrote:
On 03/08/20 20:10, John Snow wrote:

Docstrings could become part of the data format so they can be parsed,
analyzed and validated. Parsers largely treat comments like non-semantic
information and discard it. Round-trip parsers that preserve comments in
any language are extremely rare.

If the docstrings are relevant to the generator and aren't discardable,
they should be fully-fledged data members.

In a prototype I had for a YAML format, I just promoted docstrings
directly to fields, so I could allow clients to query help text for
individual commands.

This would be actually a good idea, but somebody has to write the code.
  Each field's docstring should be attached to the field, however---no
parsing needed only looking at the tree.  Take a look at what Nir posted:

Here is the patch adding schema convertor from qemu "json" format to
standard yaml:

The current version of the new yaml based schema:

     VmDiskDevice: &VmDiskDevice
         added: '3.1'
         description: Properties of a VM disk device.
         name: VmDiskDevice
         -   description: Indicates if writes are prohibited for the
             name: readonly
             type: boolean

         -   description: The size of the disk (in bytes)
             name: apparentsize
             type: uint



I was working on a small prototype that used something that looked like this; the "*opt" format was traded for "?opt", but otherwise:

  name: AudiodevPerDirectionOptions
  doc: >
    General audio backend options that are used for both
    playback and recording.
  since: '4.0'

      type: bool
      default: 'true'
      since: '4.2'
      doc: |
        Use QEMU's mixing engine to mix all streams inside QEMU and
        convert audio formats when not supported by the backend.

        When set to off, fixed-settings must be also off.

      type: bool
      default: 'true'
      doc: >-
        Use fixed settings for host input/output.
        When off, frequency, channels and format must not be specified.

      type: bool
      default: '44100'
      doc: >-
        frequency to use when using fixed settings.

      type: 'uint32'
      default: 2
      doc: >-
        Number of channels when using fixed settings.

      type: 'uint32'
      default: 1
      doc: "Number of voices to use."

      type: 'AudioFormat'
      default: 's16'
      doc: "Sample format to use when using fixed settings."

      type: 'uint32'
      doc: 'The buffer length, in microseconds.'

      since: '6.0'
      doc: 'This is, no doubt, an extremely cool feature.'

      doc: 'This is a very bad feature. I am sorry for making it.'
      since: '1.0'
      deprecated: '5.9'

reply via email to

[Prev in Thread] Current Thread [Next in Thread]