Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display no hover if there is no documentation #743

Merged
merged 1 commit into from
Jun 2, 2020

Conversation

datho7561
Copy link
Contributor

@datho7561 datho7561 commented May 28, 2020

See redhat-developer/vscode-xml#258

no-doc-no-hover

Signed-off-by: David Thompson [email protected]

@angelozerr
Copy link
Contributor

@datho7561 it should be better to fix this issue when documentation is generated. I have not tested but I think the correct fix is to move this block code https://github.com/eclipse/lemminx/blob/master/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/utils/XMLGenerator.java#L235-L248 to https://github.com/eclipse/lemminx/blob/03ca39622411febbf13b2721886985e0bcaef44c/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/utils/XMLGenerator.java#L233

For the test:

  • fix the tests by adding some xs:appinfo in docAppinfo.xsd
  • write test with empty documentation to check you return no hover.

@datho7561
Copy link
Contributor Author

@angelozerr Thanks! The only issue is that this means the completion won't display anything if there is no doc:

NoDocNoHoverLemminx

If this is okay, I'll take this route. Otherwise, I think something more involved might be required.

@angelozerr
Copy link
Contributor

angelozerr commented May 28, 2020

Completion and Hover must have the same behavior to be consistent so yes its ok

@datho7561 datho7561 marked this pull request as ready for review May 29, 2020 14:40
@fbricon
Copy link
Contributor

fbricon commented May 29, 2020

Given

<?xml version="1.0" encoding="UTF-8" ?>
<hazdoc xmlns="foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="foo ./foo.xsd">
<nodoc></nodoc>
</hazdoc>

and foo.xsd containing

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  elementFormDefault="qualified" 
  xmlns="foo" 
  targetNamespace="foo">
  <xs:element name="hazdoc">
    <xs:annotation>
      <xs:appinfo> I haz appinfo</xs:appinfo>
      <xs:documentation source="version">3.0.0+</xs:documentation>
      <xs:documentation source="description">
        
        I haz doc
        
      </xs:documentation>
    </xs:annotation>
  </xs:element>
      <xs:element name="nodoc" type="xs:string">
        <xs:annotation>
          <xs:appinfo>    </xs:appinfo>
          <xs:documentation source="version">   </xs:documentation>
          <xs:documentation source="description">

          </xs:documentation>
        </xs:annotation>
      </xs:element>
</xs:schema>

The nodoc node should not have any hover, as all its docs are blank, yet it shows a Source link on hover, with no doc.

@datho7561
Copy link
Contributor Author

Given

<?xml version="1.0" encoding="UTF-8" ?>
<hazdoc xmlns="foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="foo ./foo.xsd">
<nodoc></nodoc>
</hazdoc>

and foo.xsd containing

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  elementFormDefault="qualified" 
  xmlns="foo" 
  targetNamespace="foo">
  <xs:element name="hazdoc">
    <xs:annotation>
      <xs:appinfo> I haz appinfo</xs:appinfo>
      <xs:documentation source="version">3.0.0+</xs:documentation>
      <xs:documentation source="description">
        
        I haz doc
        
      </xs:documentation>
    </xs:annotation>
  </xs:element>
      <xs:element name="nodoc" type="xs:string">
        <xs:annotation>
          <xs:appinfo>    </xs:appinfo>
          <xs:documentation source="version">   </xs:documentation>
          <xs:documentation source="description">

          </xs:documentation>
        </xs:annotation>
      </xs:element>
</xs:schema>

The nodoc node should not have any hover, as all its docs are blank, yet it shows a Source link on hover, with no doc.

Thanks for point this out! I fixed it and added a test case for it.

If a declared element doesn't have associated `xs:documentation`
or `xs:appinfo`, then no hover information is displayed.
This also applies to the documentation displayed by the completion as
well.

Closes redhat-developer/vscode-xml#258

Signed-off-by: David Thompson <[email protected]>
@angelozerr angelozerr merged commit 2cbdd5a into eclipse-lemminx:master Jun 2, 2020
@angelozerr
Copy link
Contributor

Works like a charm, great job @datho7561 !

@xorye xorye changed the title No hover is displayed if there is no documentation Display no hover if there is no documentation Jun 10, 2020
@datho7561 datho7561 deleted the no-doc-no-hover branch January 18, 2021 20:31
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.

4 participants