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

add easy diff for document tracking #7498

Merged
merged 4 commits into from
Nov 1, 2019

Conversation

zhang2014
Copy link
Contributor

@zhang2014 zhang2014 commented Oct 27, 2019

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Category :

  • Documentation

Detailed description (optional):

for example:

☁  tools [docs/diff_script] ⚡ ./easy_diff.py zh/data_types

use stdout print :

Need translate document:/Users/coswde/Source/ClickHouse/docs/tools/../../docs/en/data_types/uuid.md

use git pager print:

diff --git a/docs/en/data_types/domains/ipv6.md b/docs/en/data_types/domains/ipv6.md
index 1bfbe3400b..e2abaff017 100644
--- a/docs/en/data_types/domains/ipv6.md
+++ b/docs/en/data_types/domains/ipv6.md
@@ -4,13 +4,13 @@
 
 ### Basic Usage
 
-``` sql
+```sql
 CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url;
 
 DESCRIBE TABLE hits;
 ```
 
-```
+```text
 ┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┐
 │ url  │ String │              │                    │         │                  │
 │ from │ IPv6   │              │                    │         │                  │
@@ -19,19 +19,19 @@ DESCRIBE TABLE hits;
 
 OR you can use `IPv6` domain as a key:
 
-``` sql
+```sql
 CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from;
... MORE

@zhang2014
Copy link
Contributor Author

This script is based on the assumption that documents in other languages are fully synchronized with the en document at a commit.

CLICK_HOUSE_REPO_HOME = os.path.join(os.path.dirname(SCRIPT_PATH), '../../')


def diffFile(reference_file, working_file, git, temp_diff):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def diffFile(reference_file, working_file, git, temp_diff):
def diff_file(reference_file, working_file, git, temp_diff):

snake_case style is more common in python for function names and as far as I remember nearby scripts use it, let's change this? (here and below)

from tempfile import NamedTemporaryFile

SCRIPT_PATH = os.path.abspath(__file__)
CLICK_HOUSE_REPO_HOME = os.path.join(os.path.dirname(SCRIPT_PATH), '../../')
Copy link
Contributor

Choose a reason for hiding this comment

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

not so important, but I think:

  • it's better to write CLICKHOUSE in one word
  • os.path.join(os.path.dirname(SCRIPT_PATH), '..', '..') looks better

working_item = os.path.join(working_directory, list_item)
reference_item = os.path.join(reference_directory, list_item)
if diffFile(reference_item, working_item, git, temp_diff) if os.path.isfile(reference_item) else diffDirectory(reference_item, working_item, git, temp_diff) != 0:
return 1
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we use this number as exit code below where we call these functions?

if __name__ == '__main__':
git = cmd.Git(CLICK_HOUSE_REPO_HOME)
git_pager = git.execute(['git', 'var', 'GIT_PAGER'])
working_language = os.path.join(CLICK_HOUSE_REPO_HOME, 'docs', sys.argv[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

We'd better start using argparse module right away to make it more flexible and extendable. For example there could be an option to skip the git pager part.

@blinkov
Copy link
Contributor

blinkov commented Oct 28, 2019

This script is based on the assumption that documents in other languages are fully synchronized with the en document at a commit.

@zhang2014 it's better to add this comment to --help output or at least in code comments

@alexey-milovidov alexey-milovidov merged commit b2f72c7 into ClickHouse:master Nov 1, 2019
@CurtizJ CurtizJ added the pr-documentation Documentation PRs for the specific code PR label Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-documentation Documentation PRs for the specific code PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants