Skip to content

[AIRFLOW-3996] Add view source link to included fragments#4894

Merged
Fokko merged 1 commit intoapache:masterfrom
PolideaInternal:viewsource-link
Mar 29, 2019
Merged

[AIRFLOW-3996] Add view source link to included fragments#4894
Fokko merged 1 commit intoapache:masterfrom
PolideaInternal:viewsource-link

Conversation

@mik-laj
Copy link
Copy Markdown
Member

@mik-laj mik-laj commented Mar 10, 2019

Make sure you have checked all steps below.

Jira

Description

I added buttons that will allow you to go to the source code of the whole file with an example.

Preview: http://bloody-boundary.surge.sh/howto/operator/bash.html

Screenshot 2019-03-10 at 23 39 46

UI component has been adapted to mobile devices.

We've discussed the different look of the header internally. It did not include a button but a clickable filename. A vote took place and this is a winning proposition.

Currently, it does not work for some GCP operator examples due to errors in their implementation. My team is planning to improve these operators in the future. I also plan that other examples should also contain the full source code and be tested on Travis - PolideaInternal#77

CC: @potiuk

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added.
    • All the public functions and the classes in the PR contain docstrings that explain what it does
    • If you implement backwards incompatible changes, please leave a note in the Updating.md so we can assign it to a appropriate release

Code Quality

  • Passes flake8

@mik-laj mik-laj changed the title [AIRFLOW-3996] Add view source link to include fragments [AIRFLOW-3996] Add view source link to included fragments Mar 10, 2019
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Mar 11, 2019

I like where it heads :). I like that it works now with mobile/smaller screen. Ie think it will be much more readable for all examples to get the links to example files!

I am quite ok with linking to the file rather than to particular part of example (it would have been much more complex to link to particular source code). But maybe we should make file names also links to the source code (similarly as in Google GCP examples. For example here: https://cloud.google.com/functions/docs/tutorials/pubsub

@mik-laj
Copy link
Copy Markdown
Member Author

mik-laj commented Mar 11, 2019

PTAL @ashb @feng-tao

Comment thread docs/conf.py Outdated
Comment thread docs/exts/exampleinclude.py Outdated
Comment thread docs/exts/exampleinclude.py Outdated
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.

Can we do this via subclassing LiteralInclude so we don't have to have so much code 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.

I know that we have a lot of code, but it is not possible to extend this class. The logic of this directive is contained in one method. There is no method that we can extend to add new expected behavior.

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.

If we subclass we at least don't have to set the option_spec and other class properties.

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.

Which version did you copy from? There are odd/subtle differences from the version linked to

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.

Unless I'm missing something (I've only had a quick look) I think we should be able to do this as something like:

    def run(self):
        _, filename = self.env.relfn2path(self.arguments[0])
        retnode, = super().run()
        container_node = nodes.container("", literal_block=True, classes=["example-block-wrapper"])
        container_node += example_header(filename=filename)
        container_node += retnode
        retnode = container_node
        return [retnode]

?

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 figured there was some auto-formatting going on)

A link to that would more helpful than master :)

The only change in option_spec is the removal of caption right? Basically there is a lot of code here that we haven't really changed, and it's hard to work out what is special and what isn't.

Copy link
Copy Markdown
Member Author

@mik-laj mik-laj Mar 14, 2019

Choose a reason for hiding this comment

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

I will prepare a detailed description of the changes that I made in the code of this class tomorrow.

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.

Can you wait with review? I did not think that this change might require such a discussion

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 might be over thinking it - still, a comment in the source would help future Us.

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.

Diff changes: https://pastebin.com/W4eHex7C
Line 1-5: I changed the name of the class. No comemnts
Line 6-15: I updated description of class. No comments
Line 16-17: I remove caption. Now, we use a filename as a caption allways.
Line 18-19 At the time of writing PR, there were no validation types in the project.
Line 20-25: There are two changes here.
a) I dropped support for translating the message. We do not support translations in the project.
b) I pass a arguments to logger. Reason available: #4804
Line 26-38.
a) I dropped caption support. It was conflicting with the new header.
b) I added a new header. This uses the file name as the header content.

Unless I'm missing something (I've only had a quick look) I think we should be able to do this as something like:

I did not find the official API to make a distinction. This is just one class and I decided it would be better to copy it. I've done research on how other people implement extensions for this directive and other people also copy the full class code
https://github.com/FabriceSalvaire/sphinx-getthecode/blob/master/sphinxcontrib/getthecode.py#L27-L32

@mik-laj
Copy link
Copy Markdown
Member Author

mik-laj commented Mar 16, 2019

I updated a PR to apply suggestion. i also deleted docs/exts/removemarktransform.py. The file is not associated with this change. The file is not associated with this change. Backup of file is available: https://gitlab.polidea.com/snippets/22

@Fokko
Copy link
Copy Markdown
Contributor

Fokko commented Mar 23, 2019

@mik-laj Can you rebase?

…lta SLAs (apache#4939)

Modify SchedulerJob.manage_slas to respect zero timedelta SLAs
@Fokko
Copy link
Copy Markdown
Contributor

Fokko commented Mar 29, 2019

Conflicts, again 🤔

@mik-laj mik-laj force-pushed the viewsource-link branch 2 times, most recently from cfefecd to e62d247 Compare March 29, 2019 10:48
@mik-laj
Copy link
Copy Markdown
Member Author

mik-laj commented Mar 29, 2019

@Fokko, I updated a PR

Comment thread docs/conf.py Outdated
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #4894 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4894   +/-   ##
=======================================
  Coverage   75.81%   75.81%           
=======================================
  Files         458      458           
  Lines       29882    29882           
=======================================
  Hits        22655    22655           
  Misses       7227     7227

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f4e24e3...72ed975. Read the comment docs.

@mik-laj
Copy link
Copy Markdown
Member Author

mik-laj commented Mar 29, 2019

@Fokko It's green.

@Fokko Fokko merged this pull request into apache:master Mar 29, 2019
@Fokko
Copy link
Copy Markdown
Contributor

Fokko commented Mar 29, 2019

The commit wasn't correct:
image

I've corrected this.

@potiuk potiuk deleted the viewsource-link branch September 19, 2019 22:45
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.

6 participants