Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtDoc: Formatting of code blocks following `\value` tables in Qml property docs
Forum Updated to NodeBB v4.3 + New Features

QtDoc: Formatting of code blocks following `\value` tables in Qml property docs

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
9 Posts 2 Posters 701 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • FeRDNYCF Offline
    FeRDNYCF Offline
    FeRDNYC
    wrote on last edited by FeRDNYC
    #1

    I noticed that, in a particular page of the Qt documentation itself (the QtQuick Text Input doc), both the docs.qt.io site and the QtAssistant rendering are showing the same formatting issue.

    \qml code blocks format fine elsewhere, but whenever one immediately follows the \value list of a \qmlproperty documentation comment, it ends up getting swallowed into the last cell in the second column of the values table.

    On the website:

    d1495f2e-c543-4e84-9382-daa3da473653-image.png

    In QtAssistant:

    884621d9-e439-4c7d-b600-2dfa01cb0630-image.png

    ...Looks bad, right? (Especially on the web, where the site template currently allows those <PRE> code blocks to blow out the document width like crazy.) And that's not the only instance, every \qmlproperty comment where a \qml block follows the \value list seems to be affected the same way. So, I'd like to fix that.

    Except... I'm not sure how. The \qml block is already set off from the \value list, in fact there's even a blank line between the last \value and the \qml block opener. Here's the existing source for that same table:

    
    /*!
        \qmlproperty int QtQuick::TextInput::font.weight
    
        The requested weight of the font. The weight requested must be an integer
        between 1 and 1000, or one of the predefined values:
    
        \value Font.Thin        100
        \value Font.ExtraLight  200
        \value Font.Light       300
        \value Font.Normal      400 (default)
        \value Font.Medium      500
        \value Font.DemiBold    600
        \value Font.Bold        700
        \value Font.ExtraBold   800
        \value Font.Black       900
    
        \qml
        TextInput { text: "Hello"; font.weight: Font.DemiBold }
        \endqml
    */
    

    ...I'm not sure how much more separated they can be, it's surprising that the formatting is going wrong the way it is.

    Does anyone have any ideas why the code block would end up being considered part of the \values table, or have any suggestions for the "Right Way™" to fix the source so that doesn't happen? I mean, I could try inserting a manual \br or an empty \span or \div, but that's already feeling really kludgey.

    1 Reply Last reply
    0
    • FeRDNYCF Offline
      FeRDNYCF Offline
      FeRDNYC
      wrote on last edited by
      #2

      (This probably isn't the right category for this question, but I couldn't find a more appropriate-sounding one.)

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        I think you might have found an issue with qdoc. Did you already check the bug report system for something similar ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        FeRDNYCF 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          I think you might have found an issue with qdoc. Did you already check the bug report system for something similar ?

          FeRDNYCF Offline
          FeRDNYCF Offline
          FeRDNYC
          wrote on last edited by
          #4

          @SGaist Somewhat, though it's not the easiest thing to search for.

          The closest I've come is this closed issue which was actually about the opposite problem, where attempts to intentionally include \image embeds inside \value lists were breaking, because the \image was forcing a new paragraph. (The fix there was to switch to \inlineimage.)

          \qml, it seems, does the opposite and refuses to begin a new paragraph, even when it's clearly separated from the preceding code by both vertical whitespace and indentation. It's kind of surprising that QtDoc seemingly doesn't consider those factors, in interpreting how to format documentation comments.

          As a result, as @shawnrutledge said at the start of the conversation on that other bug,

          I guess the trouble is you don't know when a \value should end.

          Since that bug's closed, I guess I'll file this issue as a new one, though without significant changes to how QtDoc parses documentation comments (to add much more complex interpretation of indentation and line separations) I don't see that there's much to be done about this.

          Maybe the right answer is to just insert some sort of manual break. Kludgey, but if it works...

          1 Reply Last reply
          0
          • FeRDNYCF Offline
            FeRDNYCF Offline
            FeRDNYC
            wrote on last edited by
            #5

            (The code above maybe isn't the best illustration of QtDoc's frustrating refusal to interpret whitespace into block separators, but for example this code block is also swallowed into the last value, and if this doesn't end the \value block then I don't know what will.)

            /*!
                \qmlproperty enumeration QtQuick::TextInput::font.capitalization
            
                Sets the capitalization for the text.
            
                \value Font.MixedCase       the normal case: no capitalization change is applied
                \value Font.AllUppercase    alters the text to be rendered in all uppercase type
                \value Font.AllLowercase    alters the text to be rendered in all lowercase type
                \value Font.SmallCaps       alters the text to be rendered in small-caps type
                \value Font.Capitalize      alters the text to be rendered with the first character of
                                            each word as an uppercase character
            
                \qml
                TextInput { text: "Hello"; font.capitalization: Font.AllLowercase }
                \endqml
            */
            
            1 Reply Last reply
            0
            • FeRDNYCF Offline
              FeRDNYCF Offline
              FeRDNYC
              wrote on last edited by
              #6

              Ooh, I should test whether \value is willing to take brace-wrapped arguments, like some other commands do:

              /*!
                    \qmlproperty enumeration Foo::Bar
              
                    Bars the Foo.
              
                    \value {Bar.Baz} {something something Qml something declarative.}
                    \value {Bar.Faz} {blah blah...}
              
                    \qml
                    Foo { bar.baz: "Stuff"; }
                    \endqml
              */
              

              If that works, it could solve all these problems.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hope it does but I still think that a bug report is in order at least to update the documentation where it happens.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • FeRDNYCF Offline
                  FeRDNYCF Offline
                  FeRDNYC
                  wrote on last edited by
                  #8

                  It didn't, anyway. (Sigh.)

                  The slightly weird thing is HOW it didn't work.

                  This code:

                  /*!
                      \qmlproperty int QtQuick::TextInput::font.weight
                  
                      The requested weight of the font. The weight requested must be an integer
                      between 1 and 1000, or one of the predefined values:
                  
                      \value {Font.Thin}    {100}
                      \value {Font.ExtraLight}    {200}
                      \value {Font.Light}    {300 and change}
                      \value {Font.Normal}    {400 is the (default)}
                      \value {Font.Medium}    {500}
                      \value {Font.DemiBold}    {600}
                      \value {Font.Bold}    {700}
                      \value {Font.ExtraBold}    {800a}
                      \value {Font.Black}    {900}
                  
                      \qml
                      TextInput { text: "Hello"; font.weight: Font.DemiBold }
                      \endqml
                  */
                  

                  Results in this:

                  image.png

                  But it wasn't even the \qml block. As an experimental control, I also did this:

                      \value {TextInput.QtRendering} {Text is rendered using a scalable distance field for each glyph.}
                      \value {TextInput.NativeRendering} {Text is rendered using a platform-specific technique.}
                      \value {TextInput.CurveRendering} {Text is rendered using a curve rasterizer running directly on the graphics hardware. (Introduced in Qt 6.7.0.)}
                  

                  And:
                  7f47f5bc-c71c-40ed-8a99-be88217bc365-image.png

                  Apparently, \value takes an optionally { }-delimited first argument, followed by a free-text second argument with very impenetrable and magical rules for where it ends.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    I am going to sound like a broken record but: open a ticket.
                    You have enough material to warrant either a bug fix or a documentation fix.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved