381 | | base_path = os.path.join(os.environ['SAGE_ROOT'], base_path) |
| 382 | # read the start of SAGE_ROOT/devel/sage/doc/common/builder.py |
| 383 | # to find list of languages, documents, and documents to omit |
| 384 | doc_path = os.path.join(ROOT, 'devel', 'sage', 'doc') |
| 385 | builder = open(os.path.join(doc_path, 'common', 'builder.py')) |
| 386 | s = builder.read()[:1000] |
| 387 | builder.close() |
| 388 | # list of languages |
| 389 | lang = [] |
| 390 | idx = s.find("LANGUAGES") |
| 391 | if idx != -1: |
| 392 | start = s[idx:].find('[') |
| 393 | end = s[idx:].find(']') |
| 394 | if start != -1 and end != -1: |
| 395 | lang = s[idx+start+1:idx+end].translate(None, "'\" ").split(",") |
| 396 | # documents in SAGE_ROOT/devel/sage/doc/LANG/ to omit |
| 397 | omit = [] |
| 398 | idx = s.find("OMIT") |
| 399 | if idx != -1: |
| 400 | start = s[idx:].find('[') |
| 401 | end = s[idx:].find(']') |
| 402 | if start != -1 and end != -1: |
| 403 | omit = s[idx+start+1:idx+end].translate(None, "'\" ").split(",") |
| 404 | # list of documents, minus the omitted ones |
| 405 | documents = [] |
| 406 | for L in lang: |
| 407 | documents += [os.path.join(L, dir) for dir |
| 408 | in os.listdir(os.path.join(doc_path, L)) |
| 409 | if dir not in omit] |
| 410 | # now check to see if any documents are missing. this just |
| 411 | # checks to see if the appropriate output directory exists, |
| 412 | # not that it contains a complete build of the docs. |
| 413 | missing = [os.path.join(ROOT, base_path, 'html', doc) |
| 414 | for doc in documents if not |
| 415 | os.path.exists(os.path.join(ROOT, base_path, 'html', doc))] |
| 416 | num_missing = len(missing) |
| 417 | if num_missing > 0: |
| 418 | print """Warning, the following Sage documentation hasn't been built, |
| 419 | so documentation search results may be incomplete: |
| 420 | """ |
| 421 | for s in missing: |
| 422 | print s |
| 423 | if num_missing > 1: |
| 424 | print """ |
| 425 | You can build these with 'sage -docbuild DOCUMENT html', |
| 426 | where DOCUMENT is one of""", |
| 427 | for s in missing: |
| 428 | if s.find('en') != -1: |
| 429 | print "'%s'," % os.path.split(s)[-1], |
| 430 | else: |
| 431 | print "'%s'," % os.path.join( |
| 432 | os.path.split(os.path.split(s)[0])[-1], |
| 433 | os.path.split(s)[-1]), |
| 434 | print """ |
| 435 | or you can use 'sage -docbuild all html' to build all of the missing documentation.""" |
| 436 | else: |
| 437 | s = missing[0] |
| 438 | if s.find('en') != -1: |
| 439 | s = os.path.split(s)[-1] |
| 440 | else: |
| 441 | s = os.path.join( |
| 442 | os.path.split(os.path.split(s)[0])[-1], |
| 443 | os.path.split(s)[-1]) |
| 444 | print """ |
| 445 | You can build this with 'sage -docbuild %s html'.""" % s |
| 446 | |
| 447 | base_path = os.path.join(ROOT, base_path) |