Skip to content

Libdoc: Embedding HTMl doc into XML output format. #3301 - #3302

Merged
pekkaklarck merged 10 commits into
robotframework:masterfrom
Snooz82:master
Oct 9, 2019
Merged

pekkaklarck merged 10 commits into
robotframework:masterfrom
Snooz82:master

Conversation

@Snooz82

@Snooz82 Snooz82 commented Sep 10, 2019

Copy link
Copy Markdown
Member

No description provided.

@Snooz82 Snooz82 changed the title Libdoc: Embedding HTMl doc into XML output format. Libdoc: Embedding HTMl doc into XML output format. #3301 Sep 10, 2019
@Snooz82
Snooz82 marked this pull request as ready for review September 11, 2019 22:54
@Snooz82

Snooz82 commented Sep 11, 2019

Copy link
Copy Markdown
Member Author

Hi Pekka,

I finished the implementation. Documentation is lean but should be enough.
i added a few atests and extended some others.

i would be happy if this could be reviewed quickly. ;-)
We need this feature for QS-Tag and want to show rendered Keyword Docs from Robot in our GUI.

kind regards
René

@pekkaklarck

Copy link
Copy Markdown
Member

In general looks very good. Quick comments:

  • Docs should have a note this is new in 3.2.
  • At least UG docs should be extended a little.
  • There's some unnecessary whitespace changes (trailing spaces, unnecessary empty lines, possibly inconsistent newlines).
  • The whole gven format should be validated in a one go. Initially accepting XML:whatever just complicates code elsewhere.
  • I got some small comments to code otherwise but don't have time for them right now.

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good in general but see individual line notes for things that should/could be enhanced.

Comment thread atest/robot/libdoc/doc_format.robot Resolved
Comment thread atest/robot/libdoc/cli.robot Resolved
Comment thread atest/robot/libdoc/cli.robot Resolved
Comment thread atest/robot/libdoc/cli.robot Resolved
Comment thread atest/robot/libdoc/doc_format.robot Resolved
Comment thread src/robot/libdoc.py Resolved
Comment thread src/robot/libdocpkg/writer.py Resolved
Comment thread src/robot/libdocpkg/xmlwriter.py Resolved
Comment thread src/robot/libdocpkg/xmlwriter.py Resolved
Comment thread src/robot/libdocpkg/xmlwriter.py Resolved

@Snooz82 Snooz82 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for rereview

Comment thread src/robot/libdoc.py Resolved
Comment thread atest/robot/libdoc/cli.robot Resolved
Comment thread src/robot/libdocpkg/xmlwriter.py Resolved
@Snooz82
Snooz82 requested a review from pekkaklarck September 12, 2019 16:30

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but I'd like code to be cleaned up a bit and docs to be enhanced. I also added few comments about tests, but they aren't that serious and I could fix them myself as well.

Comment thread src/robot/libdocpkg/xmlwriter.py Resolved
Comment thread src/robot/libdocpkg/xmlwriter.py Resolved
documentation, it is possible to configure
this with ``XML:HTML``. This could be used if the XML
files are used to be imported into other systems
that require HTML text to present this to a human.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's adequate to explain this kind of a feature only in the command line usage. Features should be documented so that the docs can be found easily.

The problem is that Libdoc documentation doesn't seem to have a good place to explain this. Probably the best place would be under the existing Generating documentation section, but that section should also be enhanced to explain HTML and XML formats a bit more thoroughly. I can do that if you want.

There should also be a note that this is a new feature in RF 3.2.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really appreciate, if you could add this to Libdoc documentation.
I wanted to do this but as you mentioned i could not fit this into the existing structure.
I was hard for me to "restructure" your docs.

I would recomment only to add the "new in RF 3.2" comment only in the libdoc CLI doc.
I think it really overloads the manpage without adding value to the user who is already using 3.2 when he reads this information.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added "XML:HTML is new in RF 3.2." into libdoc.rst

Comment thread src/robot/libdoc.py
documentation, it is possible to configure
this with 'XML:HTML'. This could be used if the XML
files are used to be imported into other systems
that require HTML text to present this to a human.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments about docs I wrote related to the User Guide documentation apply also to this help text. The help text doesn't need to be as thorough as User Guide, though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not disturbing the user, when it is very briefly explained here.
often Manpages are too lean. Imho.

i would let it here because in the moment it has no negative effect.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion it should be explicitly documented in the body of the help text. Usage should be short.

Comment thread src/robot/writer/filewriters.py Resolved
Comment thread src/robot/reporting/resultwriter.py Resolved
[Arguments] ${expected} ${cli}= ${lib}=DocFormat.py
${lib} = Join Path ${TESTDATADIR} ${lib}
Run Libdoc And Parse Output ${cli} ${lib}
Format should be ${expected}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this format always HTML? If yes, it should be hard coded here and the ${expected} argument removed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats correct.
i added the ${expected} to the arguments to have a better self similarity.
That a person who tries to understand the test not always habe to look into Keyword definition.

If you insist, i can remove it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An argument that isn't really used feels, well, useless for me. It also gives an impression that XML:HMTL format would support some other doc formats than HTML. I'd prefer this to be changed but don't feel strongly. If you prefer this format, leave it like that.


Compare HTML from XML:HTML
[Template] NONE
Run Libdoc -F ROBOT --format XML:HTML ${TESTDATADIR}/DocFormat.py ${OUTPREFIX}_xml_with_html.xml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could use just ${OUTXML} instead of ${OUTPREFIX}_xml_with_html.xml here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choosen this name for better understandability.
Reader should understand that this OUTXML contains HTML as doc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me a generic and pre-existing name would feel a bit better but I don't feel strongly about it. We can leave it like this as well.

Comment thread atest/robot/libdoc/doc_format.robot Resolved

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Small changes could still be done to code and tests (see separate comments), but they can also be left as-is (or I can take a look later). I can also update docs.


Compare HTML from XML:HTML
[Template] NONE
Run Libdoc -F ROBOT --format XML:HTML ${TESTDATADIR}/DocFormat.py ${OUTPREFIX}_xml_with_html.xml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me a generic and pre-existing name would feel a bit better but I don't feel strongly about it. We can leave it like this as well.

[Arguments] ${expected} ${cli}= ${lib}=DocFormat.py
${lib} = Join Path ${TESTDATADIR} ${lib}
Run Libdoc And Parse Output ${cli} ${lib}
Format should be ${expected}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An argument that isn't really used feels, well, useless for me. It also gives an impression that XML:HMTL format would support some other doc formats than HTML. I'd prefer this to be changed but don't feel strongly. If you prefer this format, leave it like that.

Comment thread src/robot/libdoc.py
documentation, it is possible to configure
this with 'XML:HTML'. This could be used if the XML
files are used to be imported into other systems
that require HTML text to present this to a human.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion it should be explicitly documented in the body of the help text. Usage should be short.

writer.element('doc', formatter(libdoc.doc))

def _write_keywords(self, type, keywords, writer):
def _write_keywords(self, writer, type, keywords, formatter):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was position of the writer argument changed? Especially having writer and formatter at the different ends of the signature feels a bit odd.

@pekkaklarck
pekkaklarck merged commit cf62b6c into robotframework:master Oct 9, 2019
@pekkaklarck

Copy link
Copy Markdown
Member

Thanks @Snooz82! I'll enhance docs separately.

writer.element('doc', formatter(libdoc.doc))

def _write_keywords(self, type, keywords, writer):
def _write_keywords(self, writer, type, keywords, formatter):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't writer an instance attribute?

@pekkaklarck pekkaklarck Oct 10, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually how @Snooz82 implemented it in the beginning. I asked him to change it because for me it would have felt a bit like misuse of the object state. It would have been fine if writer could be created in __init__, but in this case I prefer passing it as an argument similarly as formatter. Also, I prefer writer.start(...) over self._writer.start(...).

I guess this depends heavily on the personal coding style and preferences.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When coding object oriented i like to use instance attributes over handing over and returning stuff. As Pekka said, its kind of a personal style.

Because in Python the self. decreases the readability i have no real preferences here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants