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

Bring quality checks documentation within Pootle #3684

Merged
merged 2 commits into from May 6, 2015

Conversation

unho
Copy link
Member

@unho unho commented Apr 22, 2015

This staticpage also have to be created on the upgrade to 2.6. Working on that.

@translate/evernote @translate/house Please review.

Ideally Evernote checks would use the same approach it is used for TTK checks: retrieve description from each check docstring.

Also note that this doesn't handle the scenario where TTK is upgraded and new checks are added, or removed or changed.

@dwaynebailey
Copy link
Member

lgtm didn't test. I'm not sure about the unescaped & that appear in the reference EN HTML file.

@iafan
Copy link
Contributor

iafan commented Apr 22, 2015

Please note that we added some new quality checks and descriptions recently (couple of weeks ago). Is this based on most recent edits? After this PR is merged, who's going to maintain this file?

@iafan
Copy link
Contributor

iafan commented Apr 22, 2015

Yes. It could be put as & but works the same.

My personal preference to have all HTML files actually XHTML (so that they can be parsed/validated as a part of the test/build process). So I'd suggest using & everywhere (including URLs).

@unho
Copy link
Member Author

unho commented Apr 22, 2015

@iafan All Evernote quality checks have description except https://github.com/translate/pootle/blob/master/pootle/apps/pootle_misc/checks.py#L455-L463 which doesn't look like a quality check. Or at least it seems not to be used anywhere.

About maintenance. I suppose it is up to the people that adds or removes checks. IMHO it might be better to put each quality check description in the docstring, like we just did with TTK ones: translate/translate@602b9286

I am replacing the &.

@unho unho force-pushed the bring-checks-description-to-pootle branch from 0102100 to 7e840ca Compare April 22, 2015 18:53
@unho unho force-pushed the bring-checks-description-to-pootle branch 2 times, most recently from cc9004b to 0f399d8 Compare April 22, 2015 19:43
@@ -268,7 +274,7 @@ def create_default_projects():
'guide</a>.</div>'),
'virtual_path': "announcements/projects/"+tutorial.code,
}
ann = Announcement(**criteria)
ann = StaticPage(**criteria)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an error?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm just saw the change in the import. Still, I don't believe it's necessary the rename, and it's completely irrelevant in the context of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

When I first imported StaticPage was for using it on announcement creation, so I imported it as Announcement. Now that we are creating regular static pages it feels cleaner to use instead StaticPage since using Announcement can be confusing.

@julen
Copy link
Contributor

julen commented Apr 23, 2015

  • Not sure how the requirements/base.txt changes are relevant here.
  • Can we have the HTML file somewhere else please? templates/checks/descriptions.html is a good candidate.
  • Also I wonder how are descriptions supposed to be updated whenever new checks appear or disappear.

@unho unho force-pushed the bring-checks-description-to-pootle branch 2 times, most recently from 91aeb6d to 49415ea Compare April 23, 2015 11:28
@unho
Copy link
Member Author

unho commented Apr 23, 2015

  • Not sure how the requirements/base.txt changes are relevant here.

We require latest available Toolkit code, because of the changes we recently merged there (each check function now keeps its description on its docstring for easier maintenance and to ease programmatic regeneration), so I would say it is necessary.

  • Can we have the HTML file somewhere else please? templates/checks/descriptions.html is a good candidate.

I don't like the idea, but I changed it that way.

In fact I think the best approach to keep the descriptions updated would be to move them to each quality check docstring (like in TTK), but since that would take time I would leave it for future cleanups. Also I am not sure if you are even ok with this approach.

  • Also I wonder how are descriptions supposed to be updated whenever new checks appear or disappear.

There is no way to do that in this PR. Any suggestion? Maybe some management command to regenerate the whole checks descriptions staticpage?

@dwaynebailey
Copy link
Member

@unho a management command does sound like the easiest to recreate the pages, buys us time to not have to solve the further for a bit of time.

@unho unho force-pushed the bring-checks-description-to-pootle branch from 49415ea to 2f811c2 Compare April 24, 2015 17:58
@unho
Copy link
Member Author

unho commented Apr 24, 2015

@translate/evernote @translate/house Added a missing requirement and a new management command to recreate the checks descriptions on demand (docs included).

@unho unho force-pushed the bring-checks-description-to-pootle branch 2 times, most recently from 2642ef2 to fe9b5f5 Compare April 27, 2015 08:08
@julen
Copy link
Contributor

julen commented Apr 27, 2015

The new dependency on docutils for the base requirements made me think if the docstring extraction + rst2html conversion is not something better worth doing as a external/build step. After all check docstrings rarely change, and this step (and the dependency on docutils) can easily be avoided for the rest of humans. So initdb would just have to read a pre-generated HTML file and import it as an static page.

@unho
Copy link
Member Author

unho commented Apr 27, 2015

@julen So you suggest to include a static HTML page that has to be recreated on each release? Do you suggest us to handle the descriptions for the TTK checks in the same way?

@unho
Copy link
Member Author

unho commented Apr 27, 2015

@julen Let me try to explain my point a bit more clearly. Having to maintain static HTML files both in Pootle and TTK to avoid having a new dependency feels like a high toll. I see that as a maintenance nightmare, to be clear. In fact I was looking more towards even removing the existing HTML file in Pootle for the Evernote checks description, specially after @iafan asked about who is going to maintain that file (which I understood as that he sees that as maintenance burden). On the other hand I don't like the idea of pulling new dependencies.

@iafan
Copy link
Contributor

iafan commented Apr 27, 2015

I personally don't quite like what @julen have proposed: if we change the description in the bundled html file, it won't get propagated to static files in the database. We'd better simply serve this as a static page (and outside the /pages/ prefix) without having to copy it anywhere.

@julen
Copy link
Contributor

julen commented Apr 27, 2015

I personally don't quite like what @julen have proposed: if we change the description in the bundled html file, it won't get propagated to static files in the database.

This is not any new proposal, but how the code in the PR operates.

We'd better simply serve this as a static page (and outside the /pages/ prefix) without having to copy it anywhere.

Agreed, this would avoid the maintenance cost on creating a StaticPage, but as you see there's a build process (rst2html) as the TTK descriptions are pulled from the Python source directly.

@iafan
Copy link
Contributor

iafan commented Apr 27, 2015

Ok, I was probably confused by this comment of yours:

So initdb would just have to read a pre-generated HTML file and import it as an static page.

This is what I would like to avoid. We don't have to copy template into a 'static page' entity in the database just to be able to show static content. We can render it straight from the template.

@julen
Copy link
Contributor

julen commented Apr 27, 2015

Having to maintain static HTML files both in Pootle and TTK to avoid having a new dependency feels like a high toll.

Forbid me if my comment wasn't clear enough, but I'm not suggesting to maintain any HTML files on TTK. The explanation/help page is on the Pootle side, so any HTML file belong there.

Also, here a static HTML string is being generated, which is then fed to an StaticPage object. Note that at the current state of things generating the output HTML string is necessary in any case, but creating the StaticPage object adds an extra layer which can be avoided by serving the HTML directly.

@unho unho force-pushed the bring-checks-description-to-pootle branch from fe9b5f5 to a962374 Compare April 28, 2015 21:06
@dwaynebailey
Copy link
Member

@julen @iafan OK let me weigh in here. Firstly, this PR was originally done to try quickly get TTK check descriptions into Pootle and also EN check descriptions into a default install. Secondly, to make it possible to keep those well maintained without duplication. So lets keep that in mind.

I also think there is a better way to support check descriptions and that's close to the check and not in a static page. But we didn't want to go that route for this, at that would be a long fix... which ironically this quick fix is now turning into.

@julen from what I understand your issues and suggestions are these:

  1. We don't actually need a Static Page object we could just have a static HTML page (I think @iafan agrees) that Pootle is serving.
  2. We can remove the docutils dependency by simply creating the HTML file as part of the Pootle release process, instead of the build process. header+encheck+ttkchecks = static HTML file

@unho raises the following concern with this approach:

  1. TTK can be anything and thus any new TTK release would require you to generate the static page again to pick up any new checks or changed descriptions. Thus there is no one static page for TTK

My suggestion for going forward:

  1. Drop StaticPage
  2. Generate the TTK part as part of the Pootle release process
  3. Keep the management command to allow regeneration of the static HTML
  4. Move docutils dependency into dev.txt. Thus anyone wanting to update the checks page can do it.

@julen
Copy link
Contributor

julen commented Apr 29, 2015

Your understanding is correct @dwaynebailey and the suggestion is reasonable.

Also note the current StaticPage is available at /pages/help/quality-checks/. @iafan was suggesting to keep the new HTML file out of the /pages/ namespace, although it would be possible to retain the old URL if deemed necessary. Thoughts @iafan?

@unho
Copy link
Member Author

unho commented Apr 29, 2015

@julen @iafan I see no problem on having the descriptions on a static HTML that is served directly. But note that that requires to adjust the links on the editor and to agree in which URL is the static HTML going to be served.

@dwaynebailey Keeping the command to regenerate the descriptions (necessary since a given Pootle version can support multiple TTK releases with possibly different checks) pulls in the docutils dependency. If that dependency is not in base requirements we will have to warn people on docs about the need to install an extra dependency and enclose the import on a try block to avoid tracebacks in case of docutils not being available. And that is fine, despite IMHO it is not precisely user friendly.

All of this just reminded me that we have to include checks description regeneration in the upgrade instructions.

@unho
Copy link
Member Author

unho commented May 3, 2015

@translate/evernote @translate/house Reworked the whole PR. Now quality checks descriptions are being served in /help/quality-checks/ (so no more static pages). The management command now only regenerates the Translate Toolkit checks descriptions, which are saved in the checks/_ttk_descriptions.html template. Also added changes in docs, kept the requirement for the newer Toolkit and code is failsafe for docutils absence.

body = u"\n".join(filterdocs)

# Output the quality checks descriptions to the HTML file.
filename = os.path.join(
Copy link
Contributor

Choose a reason for hiding this comment

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

Better:

from django.conf import settings
filename = os.path.join(settings.WORKING_DIR,
                        'templates/checks/_ttk_descriptions.html')

@julen
Copy link
Contributor

julen commented May 4, 2015

Thanks @unho, this looks good now.

I don't believe an empty _ttk_descriptions.html needs to be under version control, and even more, it should probably be in the .gitignore file as it should be generated when creating a distribution package.

You might as well want to align file names with URLs (checks/descriptions.html -> help/quality_checks.html), but up to you.

The only concern I have is that when the command hasn't been run (or when there's no plan to use TTK checks), it still displays an empty header (Translate Toolkit Checks) and a paragraph mentioning two types of checks.
From our side we can customize that template to remove these irrelevant references and be set with that; not sure about other potential scenarios though. @iafan your thoughts on this?

GTM from my side but let's wait to hear thoughts on the previous point before merging.

@unho unho force-pushed the bring-checks-description-to-pootle branch from 53983b6 to 73017e6 Compare May 4, 2015 10:24
@unho
Copy link
Member Author

unho commented May 4, 2015

I don't believe an empty _ttk_descriptions.html needs to be under version control, and even more, it should probably be in the .gitignore file as it should be generated when creating a distribution package.

This template now contains a placeholder text saying TTK checks are not enabled.

You might as well want to align file names with URLs (checks/descriptions.html -> help/quality_checks.html), but up to you.

Done.

The only concern I have is that when the command hasn't been run (or when there's no plan to use TTK checks), it still displays an empty header (Translate Toolkit Checks) and a paragraph mentioning two types of checks.
From our side we can customize that template to remove these irrelevant references and be set with that; not sure about other potential scenarios though. @iafan your thoughts on this?

Now the Translate Toolkit Checks part displays a placeholder saying that those are not enabled. I think this approach might not be clean enough, and I have been thinking on having a third include for the problematic paragraph while having the TTK include blank. But I would like to hear from you.

@unho unho force-pushed the bring-checks-description-to-pootle branch 2 times, most recently from 1e1957f to 79e5310 Compare May 5, 2015 21:18
with codecs.open(filename, 'w', 'utf-8') as f:
f.write(body)

self.stdout.write('Regenerating descriptions... done.')
Copy link
Contributor

Choose a reason for hiding this comment

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

Realize you're repeating Regenerating descriptions here, it's already written above.

Copy link
Member Author

Choose a reason for hiding this comment

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

@julen It is intentional. Lets not force users to guess what is done.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd understand it if it was displayed as Regenerating descriptions... at the beginning, and once it's done it was overwritten with Regenerating descriptions... done. There's no guesswork involved.

Copy link
Member Author

Choose a reason for hiding this comment

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

@julen Ok, changing this so you can gtm.

@julen
Copy link
Contributor

julen commented May 5, 2015

I don't believe an empty _ttk_descriptions.html needs to be under version control, and even more, it should probably be in the .gitignore file as it should be generated when creating a distribution package.

This template now contains a placeholder text saying TTK checks are not enabled.

The core issue I was trying to highlight wasn't the fact of having an empty file. It was about the fact of having a target file which can be generated and therefore possibly end up accidentally modified in version control, potentially creating conflicts or causing other trouble that can initially be avoided.

<h2>Translate Toolkit Checks</h2>


<p>This server has not enabled the Translate Toolkit quality checks.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Why have this at all if the server is not using TTK checks?

@dwaynebailey
Copy link
Member

@unho did a review and the generation works.

One concern. The docs that we're replacing in TTK have full description of checks, much like Evernote. Yet in the autogenerated ones we only have the first line of the content.

Is this a bug, the code looks like it wants to give the full description. Or was it intentional?

@unho unho force-pushed the bring-checks-description-to-pootle branch from 79e5310 to 65ac1ff Compare May 6, 2015 07:35
@unho
Copy link
Member Author

unho commented May 6, 2015

One concern. The docs that we're replacing in TTK have full description of checks, much like Evernote. Yet in the autogenerated ones we only have the first line of the content.

Is this a bug, the code looks like it wants to give the full description. Or was it intentional?

@dwaynebailey That might be you not having upgraded translate-toolkit dependency. Note that we require the latest version on git. Once we release 1.13 final we will require that.

@dwaynebailey
Copy link
Member

@unho spot on it was an older toolkit instead of the one from Git. With a new version from github this works as expected.

@unho unho force-pushed the bring-checks-description-to-pootle branch from 65ac1ff to 784f1bc Compare May 6, 2015 11:00
@unho
Copy link
Member Author

unho commented May 6, 2015

@translate/house @translate/evernote All issues have been addressed. Now the help/_ttk_quality_checks.html template is not being added and is on the gitignore. Also all the references to toolkit or Evernote have been removed and the CSS styles are now in the stylesheets. Any other issue or gtms?

@unho unho force-pushed the bring-checks-description-to-pootle branch from 784f1bc to 5e2af4b Compare May 6, 2015 11:07

<p>Pootle has an ability to check for common translation mistakes. Once you submit a translation, it will compare its certain features with the original string and identify potential problems. Сhecks are displayed in the upper right corner, just above the submit button. Once there are checks in red, you will stay on the same unit, until you have each check resolved or muted. Note that you should only mute checks if you know what you're doing. Muted checks will be reviewed periodically by the managers.</p>

<p>If you are not sure what a particular error means and how to fix it properly, use <i>"Report a problem with this string"</i> link at the top of the unit. The managers will try to assist you as soon as possible.</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Realize this only applies if CAN_CONTACT = True

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed that, despite the string errors report form is displayed indepedently of the value of CAN_CONTACT.

@unho unho force-pushed the bring-checks-description-to-pootle branch from 5e2af4b to f3bd6a0 Compare May 6, 2015 11:19
This allows us to have a specific URL pattern to refer to them.

Note that the help/_ttk_quality_checks.html template is not added since
it is intended to be automatically generated.

Part of translate#3604.
@unho unho force-pushed the bring-checks-description-to-pootle branch from f3bd6a0 to 991e541 Compare May 6, 2015 11:58
@unho
Copy link
Member Author

unho commented May 6, 2015

@translate/house @translate/evernote Any new issue?

@dwaynebailey
Copy link
Member

@unho lgtm

The resulting descriptions are saved as the help/_ttk_quality_checks.html
template. That filepath is added to ignore in order to avoid inadvertently
commits changes in this template.

This requires the latest available code of Translate Toolkit in order
to work as expected.

The docutils library is also required. If not present an error message is
displayed asking for it.

Fixes translate#3604.
@unho unho force-pushed the bring-checks-description-to-pootle branch from 991e541 to e63082c Compare May 6, 2015 20:10
@unho unho merged commit e63082c into translate:master May 6, 2015
@unho unho deleted the bring-checks-description-to-pootle branch May 6, 2015 20:13
@unho
Copy link
Member Author

unho commented May 6, 2015

Merged since it seems I have gtms from both sides. If any other issue arises it can be fixed on master.

dwaynebailey added a commit that referenced this pull request May 22, 2015
This reverts commit 6008d34.

Here's the comment in the original PR about why it shouldn't be there
#3684 (comment)
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.

None yet

4 participants