ソースコードドキュメンテーションツールを作りたい
参考: https://pycco-docs.github.io/pycco/
- tree の結果をHTMLにして、各階層、各ファイル、ファイルの中の記述内容に対してメモできるツール。画像の埋め込めるように。
- 2ペイン。左がツリー、右がdoc
- 各ページ、各注釈はハイパーリンクを持つ
サーバー、クライアント型になると思う。 オリジナルのファイルをコピーして内包しつつ、各ノードごとのメタデータファイルを持つ。
from django.utils import timezone | |
from django.utils.dateparse import parse_datetime | |
def parse_aware_datetime(datetime_str): | |
"""see: https://stackoverflow.com/questions/8636760/parsing-a-datetime-string-into-a-django-datetimefield""" | |
ret = parse_datetime(datetime_str) | |
return timezone.make_aware(ret) if not timezone.is_aware(ret) else ret |
import calendar | |
from datetime import datetime, timedelta | |
def get_year_months_list(start_date, end_date): | |
""" | |
>>> start, end = datetime(2017, 1, 31, 0, 0), datetime(2017, 3, 15, 0, 0) | |
>>> get_year_months_list(start, end) | |
[datetime.datetime(2017, 1, 1, 0, 0), datetime.datetime(2017, 2, 1, 0, 0), datetime.datetime(2017, 3, 1, 0, 0)] | |
""" | |
start_first_day = start_date.replace(day=1) |
ソースコードドキュメンテーションツールを作りたい
参考: https://pycco-docs.github.io/pycco/
サーバー、クライアント型になると思う。 オリジナルのファイルをコピーして内包しつつ、各ノードごとのメタデータファイルを持つ。
$ ls
a1/ a2/ db.sqlite3 manage.py* mysite/
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.db.models import F, Case, When, FloatField | |
from myapp import models | |
md = models.MyModel.objects.filter(pk=3).annotate(pr=Case(When(price__gte=40., then=F('price') * 10), default=F('price') / 10, output_fields=FloatField())).first() | |
In [27]: md.price | |
Out[27]: 40.7424047560126 | |
In [29]: md.pr | |
Out[29]: 407.424047560126 |
import time | |
import sys | |
from celery import Celery | |
from celery.concurrency import asynpool | |
asynpool.PROC_ALIVE_TIMEOUT = 2 | |
app = Celery( | |
'celery_sample', | |
) |
see: https://github.com/waylan/beautifulsoup/blob/master/bs4/dammit.py#L49
html_meta_re = re.compile(
'<\s*meta[^>]+charset\s*=\s*["\']?([^>]*?)[ /;\'">]'.encode(), re.I)
Methods.
"""データベースモデル.""" | |
import datetime | |
import peewee | |
from playhouse.pool import PooledMySQLDatabase | |
db = PooledMySQLDatabase( | |
'aozora_bunko', | |
max_connections=8, | |
stale_timeout=10, |
import UIKit | |
import TwitterKit | |
import FBSDKShareKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
guard !title.isEmpty, !body.isEmpty, !url.isEmpty else { | |
return | |
} |